Hello, I've been getting into python and reading a book to get used to it, but I'm having some trouble understanding a part about while loops.
done = False
while not(done):
quit = input("Do you want to quit? ")
if quit == "y":
done = True;
attack = input("Does your elf attach the dragon?")
if attack == "y" :
print ( " Bad choice , you died . " )
done = True ;
Whenever I input anything into quit it just says that it wasn't defined, and when I try defining y like : y = "y" or something it doesn't actually quit. And this is straight from the book I am learning from.
And also, what books or tutorials would you recommend?
Hello, I've been getting into python and reading a book to get used to it, but I'm having some trouble understanding a part about while loops.
done = False
while not(done):
quit = input("Do you want to quit? ")
if quit == "y":
done = True;
attack = input("Does your elf attach the dragon?")
if attack == "y" :
print ( " Bad choice , you died . " )
done = True ;
Whenever I input anything into quit it just says that it wasn't defined, and when I try defining y like : y = "y" or something it doesn't actually quit. And this is straight from the book I am learning from.
And also, what books or tutorials would you recommend?
I'm not a python man, but I done a bit of reading around your problem. Look like Input() expects a python expression to be entered as input to be evaluated. I think the function you want to use for general input from a user is raw_input().
Hello, I've been getting into python and reading a book to get used to it, but I'm having some trouble understanding a part about while loops.
done = False
while not(done):
quit = input("Do you want to quit? ")
if quit == "y":
done = True;
attack = input("Does your elf attach the dragon?")
if attack == "y" :
print ( " Bad choice , you died . " )
done = True ;
Whenever I input anything into quit it just says that it wasn't defined, and when I try defining y like : y = "y" or something it doesn't actually quit. And this is straight from the book I am learning from.
And also, what books or tutorials would you recommend?