PYTHON LESSON

Topic 28/63 · Phase 3: Data Mastery

Slicing — Python lesson on EduBard (phase: Data Mastery)

Slicing

Main idea

Slicing takes a window from sequence using start:stop:step.

Tip

Remember stop is excluded.

Watch out

Off-by-one errors.

Read this next

You will study Slicing. It belongs to the Data Mastery phase.

Remember this:
Slicing takes a window from sequence using start:stop:step.

Practice step by step. Do not rush. Each run should show you something new.

Tip:
Remember stop is excluded.

Avoid this:
Off-by-one errors.

Your challenge:
Reverse a string and take every second char.

Go to the challenge lab below. Fix errors until the output looks right. Then press the green button to complete the topic.

Example code

Copy this example if it helps. Change it so it matches Slicing.

# Topic: Slicing
def main():
    sample = "edit me"
    # TODO: apply Slicing concept here
    result = sample
    print("Result:", result)

if __name__ == "__main__":
    main()

Challenge

Reverse a string and take every second char.

Before you can finish: your output should include at least 16 characters; at least 1 non-empty line(s); no crash traceback—fix errors until the program runs cleanly.

Use Run. Read the output. Change your code until the task is done.

Starter reference

# Challenge starter for Slicing
def solve():
    # Write your solution here
    pass

print("Update solve() and run")

Your code

The first Run may load Python in your browser (one-time). Later runs are faster.



    
    

Navigation