Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Dorota Parzych
Dorota Parzych
5,706 Points

code problem-syntax error

num = input("Please enter number: ")

def how_big(number): if number <= 10 print("za malo") else number > 11 print("za dużo") elif number == 11 print("Idealnie")

how_big(num)

Inline 4 there is a syntax error - don't know how to fix it

2 Answers

See the first example here. It is close to what you are trying to do. Notice:

  • if, elif, else statements end with a colon
  • else comes last and has no condition. It is what runs when all other conditions are false
  • the input is converted to an integer before being compared to other numbers
Dorota Parzych
Dorota Parzych
5,706 Points

so now it looks like this... num = input("Please enter number: ")

def how_big(number): if int(number) <= 10: print("not enough") elif number == 11: print("perfect") else : print("too much")

how_big(num)

Generally, it works but when I type 11 it shows me that it is too much - why and how to fix that?

Convert number to int before passing to the function. This can be done with the input:

num = int(input("Please enter number: "))

def how_big(number):
  if number <= 10:
    print("not enough")
  elif number == 11:
    print("perfect")
  else :
    print("too much")

how_big(num)