-2

I’m a beginner and I’m trying to create a program that allows users to pick a name for their rover. The program is supposed to work by asking the user what they want to name their rover, if they’re sure about it, and then finalize it. If not, then they keep redoing it until they decide on a name. The code is written in Python. Here’s what I have done so far:

    nameofbot = input("What would you like to name your rover?  ")
surity = input("Are you sure?")
surity = "Yes":
  print(nameofbot)

else:
  print("Let's try this again.")
  def multiply(

print("It is...")
time.sleep(3)
print(nameofbot)   

Note: I am trying to make it repeat all code from ‘nameofbot’ to the end of line two. Thanks for your help!

Oceantic
  • 13
  • 1

2 Answers2

0

You could run it in a loop until the user gives the input you desire, like:

surity = ""
while surity != "Yes":
    nameofbot = input("What would you like to name your rover?  ")
    surity = input("Are you sure?")

This will keep on running until surity = "Yes" when it will escape the loop.

Ismail Hafeez
  • 730
  • 3
  • 10
-1
flag = True
while(flag):
    bot_name = input("What would you like to name your rover? \n")
    surity = input("Are you sure? \n")
    if surity == "Yes":
      print(bot_name)
      flag = False
     

This should help you. The flag will be True till user is no sure about the name thus the while loop will run, if he is sure the flag is set to False and we exit the loop.