pyython code copied 1to1 from book not working. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: pyython code copied 1to1 from book not working. (/thread-8449.html) |
pyython code copied 1to1 from book not working. - BlackReptile - Feb-21-2018 Hello im a Programming Beginner and learning form a book. Everything worked so far extemley well and im making Progress but this Python Script doesnt seem to work. I get syntax error on ELIF and i dont know why. #initzialize random number generator import random random.seed() #init variables a = random.randint(1,100) b = random.randint(1,100) c = a + b #Question print ("Die Aufgabe lautet:", a, b) #userinput print ("Bitte Zahl eingeben:") zahl = input() zahl = float(zahl) #results if zahl == c: print("Super Das Ergebnis ist richtig") elif zahl < 0 or zahl > 100: print("Ganz Falsch") elif zahl c-1 <= zahl <= c+1: #in this line im getting syntax error. ELIF is red underlined. and i dont know why print("Du bist ganz nahe dran") else: print("Falsch")Thank You For your Help :) RE: pyython code copied 1to1 from book not working. - Windspar - Feb-21-2018 line 25 elif zahl(EXTRA zahl or SOMETHING_MISSING_HERE) c-1 <= zahl <= c+1: RE: pyython code copied 1to1 from book not working. - abhin - Feb-21-2018 You probably wanted line 25-26 to be elif c-1 <= zahl <= c+1: print("Du bist ganz nahe dran") |