12th Nov 2022, 11:59 PM
Bryce Fort
Bryce Fort - avatar
4 Answers
+ 5
Bryce Fort , we can also use a reverse iterator: (it is simple to use, efficient and has very low memory consumption) print("**********TEXT REVERSER**********") txt = input("Enter any word or jumble of letters and reverse it here: \n") for i in reversed(txt): print(i,end="")
13th Nov 2022, 12:17 PM
Lothar
Lothar - avatar
+ 2
Bryce Fort you can also try it like this print("**********TEXT REVERSER**********") txt = input("Enter any word or jumble of letters and reverse it here: ") print(txt[::-1])
13th Nov 2022, 7:32 AM
Toymak3r
+ 1
Bryce Fort an easy way but not the only way is .. print("**********TEXT REVERSER**********") txt = input("Enter any word or jumble of letters and reverse it here: \n") x = len(txt) y = x for i in range(y): r = txt[x-1] print(r,end="") x -= 1 As you can see the while True loop was removed as well as your if statement. AND you were not only inputting txt as a string but there was no need to also create an array as txt = []
13th Nov 2022, 5:36 AM
BroFar
BroFar - avatar
0
You can't, except there is a prompt for input just like the input function
13th Nov 2022, 12:48 AM
Toymak3r