Python

Dorota Parzych
Dorota Parzych
1,870 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

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 48,710 Points

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
1,870 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?

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 48,710 Points

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)