Problem with game

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hollandlucas@gmail.com

    #1

    Problem with game

    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."

  • hollandlucas@gmail.com

    #2
    Re: Problem with game

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



    Comment

    • irstas@gmail.com

      #3
      Re: Problem with game

      On Mar 24, 5:20 pm, hollandlu...@gm ail.com wrote:
      File "Python-episode12-Zahlenraten.py" , line 15
      print "Die eingegebene Zahl ist kleiner als die generierte Zahl."
      >
      IndentationErro r: 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.


      Comment

      Working...