Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. user_str = "aabbcc"
  2. # a a b b c c
  3. # 0 1 2 3 4 5
  4.  
  5. sub_str1 = user_str[2:]
  6. sub_str2 = user_str[1:4]
  7. sub_str3 = user_str[1::2]
  8. sub_str4 = user_str[:-2]
  9.  
  10. print(sub_str1)
  11. #bbcc
  12.  
  13.  
  14. print(sub_str2)
  15. #abb
  16. #(not inclusive of the top bound)
  17.  
  18.  
  19. print(sub_str3)
  20. #starts at the left number, adds the right number to the index
  21.  
  22.  
  23. print(sub_str4)
  24. #starting from end, minus it
  25.  
  26. index_int = 0
  27. print(user_str[index_int],user_str[index_int+2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement