Problem with game

H

hollandlucas

Hello,

the following script (it's in German):

import random
print "Wie oft wollen Sie spielen?"
anzahl_spiele = input()
games = 0
while games < anzahl_spiele:
games += 1
print "Raten sie die Zahl, die vom Computer generiert wird!"
random_number = random.randint(1, 100)
user_number = 0
counter = 0
while user_number != random_number:
user_number = input ("Zahl eingeben: ")
counter += 1
if user_number < random_number:
print "Die eingegebene Zahl ist kleiner als die generierte
Zahl."
elif user_number > random_number:
print "Die eingegebene Zahl ist groesser als die generierte
Zahl."
print "Sie haben gewonnen!"
print counter

yields the following error when run:

File "Python-episode12-Zahlenraten.py", line 15
print "Die eingegebene Zahl ist kleiner als die generierte Zahl."
 
H

hollandlucas

File "Python-episode12-Zahlenraten.py", line 15
print "Die eingegebene Zahl ist kleiner als die generierte Zahl."
IndentationError: expected an indented block
 
I

irstas

IndentationError: expected an indented block

You should indent stuff inside if-statement deeper than the if itself.

I.e. NOT LIKE THIS:

if x==3:
print x


But like this:

if x==3:
print x


If in your editor it looks like you have done this, the error
is probably that you are mixing tabs and spaces as indentation
and your editor doesn't display tabs as 8 spaces. This leads to
an amazing visual illusion cunnigly developed to turn people away
from Python.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top