0
Question about dice Sim Python script. (lower() command and user input)
Not sure what's happening with the lower() command in my script. When the input is put in lower case y or yes it allows upper and lower in any order. But the reverse only allows inputs of lower case. Why is that? Also on a side note how hard would it be for a bigginer (this is my first script) to add an option to this to either select a preset dice with a differnt amount of faces or choose your own amount? https://code.sololearn.com/cW2TpSjWh351/?ref=app https://code.sololearn.com/cW2TpSjWh351/?ref=app https://code.sololearn.com/cW2TpSjWh351/?ref=app
3 Respostas
+ 1
Your code has several errors.
Here is a revised version, you should study Python a bit more because your logic of how the language works is flawed:
import random
repeat=True
while repeat:
print("You rolled a" + random.randint(1,6))
answer = input("Roll again? Y/N").lower()
if (answer == "y" or answer == "yes"):
repeat = True
else:
repeat = False
Edit: forgot the lower() earlier
+ 1
For question 2: all you would need for different amounts of faces is one more input asking for the amount of faces (assuming you are using all the numbers up to it) and store this in a variable. Then put this variable in place of the 6 in randint
0
Thanks a bunch. Yea what you are seeing there is my first attempt at coding without a tutorial. I've only been studying Python for 3 days now and am trying to work on some simple projects to deepen my understanding.
Going to try implementing a variable into it now, thanks for your help :)