user6862018
user6862018

Reputation:

how to i get my code to loop to the input after getting the first input?

this is my code:

a = input("Enter word here: ")
print("Reverse is", a[::-1])

this is my result:

Enter word here: patronus
Reverse is sunortap

this is what I want:

Enter word here: patronus
Reverse is sunortap
Enter word here: 

I want it to ask for new words 10 times before it terminates.

Upvotes: 1

Views: 72

Answers (2)

Brndn
Brndn

Reputation: 846

for i in range(10):
    a = input("Enter word here: ")
    print("Reverse is", a[::-1])

This works by looping 10 times. You can test it by printing i within the for loop.

Upvotes: 1

Itachi Uchiha
Itachi Uchiha

Reputation: 327

for x in range(10):
  a = input("Enter word here: ")
  print("Reverse is", a[::-1]) 

Upvotes: 0

Related Questions