0

Pls can anyone modify this script for me. So that the users can input "roll" more than once

command = "" started = True win_number = 6 while command != quit: import random command = input("> ").lower() if command == "start": if started: print ("hey! the game is already on") else: started = True print ("game has started") elif command == "stop": if not started: print ("hey! the game is off") else: started = False print("game has stopped") elif command == "roll": if not started: print ("hey! start the game first") else: started = False print (random.randint(0, 6)) elif command == "help": print (""" start - start roll - roll lucky numbers stop - stop quit - end game """)

6th Apr 2022, 2:05 AM
Terrible Money
Terrible Money - avatar
6 Réponses
+ 2
elif command == "roll": if not started: print( "hey! start the game first" ) else: # started = False print( random.randint( 0, 6 ) ) You set <started> to False there ☝ + Place module import statement on top of code. + compare <command> with "quit" rather than quit (not a string) in loop condition. while command != "quit":
6th Apr 2022, 5:46 AM
Ipang
+ 1
It just allows us to input "roll" more than once. Can you elaborate more on that please?
6th Apr 2022, 2:42 AM
Simba
Simba - avatar
+ 1
looks like you want 1) to input commands 2) run game based on command given 3) roll, if game has started your pseudo-code can already take input(command) more than once but in SoloLearn you can't input more than once. I mean all the inputs should be given at the starting of your code. You can't give input in the middle of a running program. if you tried to give inputs in the middle of a running program, you will see EOF error
6th Apr 2022, 2:49 AM
NonStop CODING
NonStop CODING - avatar
+ 1
Thanks bro
6th Apr 2022, 7:28 AM
Terrible Money
Terrible Money - avatar
0
Ok i mean when the user types roll it randomly output a number range 6 but when the user tries it for the second time the script will give a reply "start the game first" unless he or she type start before it will roll
6th Apr 2022, 2:45 AM
Terrible Money
Terrible Money - avatar
0
Ok noted thanks bro
6th Apr 2022, 2:50 AM
Terrible Money
Terrible Money - avatar