0
How do I stop input from happening first?
I created a basic random dice rolling code. I'm still learning if/else and decided to add that and input into the code. The input part always pops up first before everything prints. How can I get it to print the first roll of the dice first then print everything else later? The code is below. import random #dice rolling simulator print ("Dice One:", random.randrange(1, 6)) print ("Dice Two:", random.randrange(1, 6)) print ("Roll again?") dice = input if "yes": print ("Dice One:", random.randrange(1, 6)) print ("Dice Two:", random.randrange(1, 6)) else: print ("Thanks for playing")
1 Antwort
+ 4
You're testing your script in code playground isn't it?
Well, it's a little restrictive, you cannot do all like offline, by compiling and especially by running :(
One of these restriction, is for input: you are constrained to give ALL the entries your script need ( each separated by a new line ) in the pop-up just before execution in fact... So, you can just simulate interactivity :(
Test your script at home, I mean in real on your OS and not in the code playground simulator ( but it makes great services anyway ^^ )