dice - Very basic python -
An error is occurring but I do not know why .. (I'm learning) my code; Error; (Some scripts work) At the top of what the answers are saying, I recommend that you do not use In addition, a loop instead of a Import random inputs ("press enter to roll dice") Global Answer DRP Roll (Degree): Results = Random.RandRange (1,6) Print ("Landed it . "+ Str (Result) Answer = Input (" Would you like to play again? [Y / n] ") rollDice (); If (answer == "Y" or "Y"): rollDice ();
Enter the dice to roll it to land ..5 Do you want to play again? [Y / n] Y traceback (most recent call final): file "diceRoller.py", line 11, & lt; Module & gt; Name (Answer == "Y" or "Y"): Name: Error: Name 'Answer' is not defined
global , instead I will write
return For example:
import random input (press "enter to roll the dice") def roll (): result = random Answer: "It has gone wrong again", "it landed on .." + str (result) Answer = input (a) .randrange (1,6) print () in the north ("Y", "Y") "Do you want to play again?" [Y / n] ") RollDice (): Continue
if statement Use Otherwise you will not be able to ask the user whether he wants to continue indefinitely.
Comments
Post a Comment