Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- user_str = "aabbcc"
- # a a b b c c
- # 0 1 2 3 4 5
- sub_str1 = user_str[2:]
- sub_str2 = user_str[1:4]
- sub_str3 = user_str[1::2]
- sub_str4 = user_str[:-2]
- print(sub_str1)
- #bbcc
- print(sub_str2)
- #abb
- #(not inclusive of the top bound)
- print(sub_str3)
- #starts at the left number, adds the right number to the index
- print(sub_str4)
- #starting from end, minus it
- index_int = 0
- print(user_str[index_int],user_str[index_int+2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement