Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # string to tuple
- my_string = input('Enter a string: ')
- tup1 = tuple(my_string)
- print(tup1)
- # string to list (tup1)
- s1 = list(my_string)
- print(s1)
- # prints list in reverse
- s2 = []
- for i in range(len(s1)):
- s2.append(s1[-(i+1)])
- print(s2)
- # string to list (tup2)
- tup2 = tuple(s2)
- print(tup2)
- # finds the number value of element
- s3 = []
- for i in range(len(s1)):
- s3.append(ord(s1[i]))
- print(s3)
- tup3 = tuple(s3)
- print(tup3)
- # sorts elements from smallest to largest
- s3.sort()
- print(s3)
- tup4 = tuple(s3)
- print(tup4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement