Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Quick recap
Indexing and slicing
Summary
16. Summary

Instruction

All right, it's time to wrap things up.

  1. text = 'a' or text = "a" creates a string.
  2. string[2] gets the third string character.
  3. string[2:5] gets characters with the indices 2 (inclusive) to 5 (exclusive).
  4. string[2:] gets all the characters starting at index 2.
  5. string[-1] gets the last string character.
  6. string[2:50:3] gets every third character from index 2 (inclusive) until index 50 (exclusive).
  7. string[::-1] reverses the string.
  8. \ escapes special characters, including itself.
  9. + joins strings.
  10. '-'.join(string_list) joins all elements in a string_list and separates them with a '-'.
  11. if 'a' in string checks whether the string contains at least one letter 'a'.
  12. for letter in string iterates over the string.

How about a short quiz now?

Exercise

Click Next exercise to continue.