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
  is this really a syntax error? Skaperen 4 358 May-25-2024, 07:31 AM
Last Post: snippsat
  World Clock syntax error OscarBoots 1 321 May-03-2024, 05:20 AM
Last Post: snippsat
  Syntax error for "root = Tk()" dlwaddel 15 1,614 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 552 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 1,930 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,420 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,867 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  syntax error question - string mgallotti 5 1,484 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,429 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 1,030 Dec-05-2022, 06:38 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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