Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax error in if line
#5
Thank you. The thing is that I try to follow various tutorials and not all of them specify version of Python, I will do better.

As I understand using just IF would give me 3 outputs for the value 25, because it's less than 45, 70 and 100. I thought this can be avoided by using elif and you will get just one output for the value 25, which is the desired "we can still go running, let's grab something and go".

This is what I was trying to copy:
[Image: fRVHuk]
Did I understand everything wrong?

The code now works as I wanted it to. No idea how it happened.

lazy = int(input("How lazy are you? (write number 1-100) "))
if lazy < 20:
    print("Go RUN RUN RUN")
elif lazy < 45:
    print("we can still go running, let's grab something and go")
elif lazy < 70:
    print("okay, let's just go for a walk")
elif lazy <= 100:
    print("Hm, let's just grab some nice coffee")
else:
    print("hey, that's too much lazy, you were supposed to be max lazy 100, you lazy girl!")
Reply


Messages In This Thread
Syntax error in if line - by daniel - Jul-24-2017, 07:22 AM
RE: Syntax error in if line - by DeaD_EyE - Jul-24-2017, 08:06 AM
RE: Syntax error in if line - by daniel - Jul-24-2017, 08:18 AM
RE: Syntax error in if line - by DeaD_EyE - Jul-24-2017, 08:23 AM
RE: Syntax error in if line - by daniel - Jul-24-2017, 08:39 AM
RE: Syntax error in if line - by DeaD_EyE - Jul-24-2017, 09:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas - error when running Pycharm, but works on cmd line zxcv101 2 2,573 Sep-09-2024, 08:03 AM
Last Post: pinkang
  POST Syntax error amplay 0 710 Aug-07-2024, 02:43 PM
Last Post: amplay
  is this really a syntax error? Skaperen 4 1,761 May-25-2024, 07:31 AM
Last Post: snippsat
  World Clock syntax error OscarBoots 1 1,209 May-03-2024, 05:20 AM
Last Post: snippsat
  Syntax error for "root = Tk()" dlwaddel 15 7,166 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 1,431 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 5,812 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 3,211 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 15,716 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  syntax error question - string mgallotti 5 2,836 Feb-03-2023, 05:10 PM
Last Post: mgallotti

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020