Re: trying to make a simple program help please :)
On 14/10/2016 19:53, LongHairLuke wrote: Den fredag 14 oktober 2016 kl. 20:30:20 UTC+2 skrev MRAB: On 2016-10-14 19:11, LongHairLuke wrote: Hi, l l am trying to make a simple guess program. This is my script: def main(): print ("Guess a letter between a and e") randomNumber = b userGuess = input("Your guess: ") if userGuess == randomNumber: print("You got it") else: print ("That's not it") main() When l run the program l get error: userGuess is not defined, but l defined userGuess at line 5. I don't get it someone plese help :) Lines 7 to 10 should be indented like the preceding lines. The way you've written them, they're outside 'main'. indented? can you explain :) def main(): print ("Guess a letter between a and e") randomNumber = b userGuess = input("Your guess: ") if userGuess == randomNumber: print("You got it") else: print ("That's not it") main() (Python doesn't have explicit block-end delimiters. The end of a block (of the one compromising the body of function main in this case) has to be inferred from encountering some statement at the same or lower indent level than the opening 'def'. Or the end of the file.) Anyway, the above won't completely fix the program as you haven't defined b, although you may have intended "b", even though you've called the variable 'randomNUMBER'. With "b" in place of b, the program works on Python 3, although it doesn't verify bad inputs. -- Bartc -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to make a simple program help please :)
Right, another troll. plonk Irmen -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to make a simple program help please :)
Den fredag 14 oktober 2016 kl. 20:30:20 UTC+2 skrev MRAB: > On 2016-10-14 19:11, LongHairLuke wrote: > > Hi, l l am trying to make a simple guess program. This is my script: > > > > def main(): > > print ("Guess a letter between a and e") > > randomNumber = b > > > > userGuess = input("Your guess: ") > > > > if userGuess == randomNumber: > > print("You got it") > > else: > > print ("That's not it") > > > > main() > > > > > > When l run the program l get error: userGuess is not defined, but l defined > > userGuess at line 5. I don't get it someone plese help :) > > > Lines 7 to 10 should be indented like the preceding lines. The way > you've written them, they're outside 'main'. indented? can you explain :) -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to make a simple program help please :)
On 14-10-2016 20:11, LongHairLuke wrote: > Hi, l l am trying to make a simple guess program. This is my script: > > def main(): > print ("Guess a letter between a and e") > randomNumber = b > > userGuess = input("Your guess: ") > > if userGuess == randomNumber: > print("You got it") > else: > print ("That's not it") > > main() > > > When l run the program l get error: userGuess is not defined, but l defined > userGuess at line 5. I don't get it someone plese help :) > > Lukas Alberts > The indentation of the if/else statement in your program is off. Fix it by properly indenting the if-else to be at the same indentation level as the other lines that should be part of the main() function. Irmen -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to make a simple program help please :)
On 2016-10-14 19:11, LongHairLuke wrote: Hi, l l am trying to make a simple guess program. This is my script: def main(): print ("Guess a letter between a and e") randomNumber = b userGuess = input("Your guess: ") if userGuess == randomNumber: print("You got it") else: print ("That's not it") main() When l run the program l get error: userGuess is not defined, but l defined userGuess at line 5. I don't get it someone plese help :) Lines 7 to 10 should be indented like the preceding lines. The way you've written them, they're outside 'main'. -- https://mail.python.org/mailman/listinfo/python-list
trying to make a simple program help please :)
Hi, l l am trying to make a simple guess program. This is my script: def main(): print ("Guess a letter between a and e") randomNumber = b userGuess = input("Your guess: ") if userGuess == randomNumber: print("You got it") else: print ("That's not it") main() When l run the program l get error: userGuess is not defined, but l defined userGuess at line 5. I don't get it someone plese help :) Lukas Alberts -- https://mail.python.org/mailman/listinfo/python-list