Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- text=input("Input text:")
- #loops
- text2=[]
- textrev2=''
- for i in range(len(text)):
- text2.append(text[-(i+1)])
- textrev2=textrev2+text2[i]
- print("Using loops", textrev2)
- # slices
- print("Using slices:", text[::-1])
- #reversed (hasd to do a bit Googling here, because the "list" in fron of reversed was not obvious)
- textrev3=''
- text3=list(reversed(text))
- for i in text3:
- textrev3=textrev3+str(i)
- print("with reveresed:", textrev3)
Add Comment
Please, Sign In to add comment