"SyntaxError: invalid syntax" error [closed]

0

I was trying to run a very simple program through the terminal (use ubuntu gnome):

#encoding: utf-8
y = int(input("Ultimo número: "))
x=0
while x <= y
   if x % 2 == 0
     print (x)
   x=x+1

and I came across the following error:

File "pares.py", line 4

    while x <= y
               ^
SyntaxError: invalid syntax

What is the cause of the problem in this case?

    
asked by anonymous 06.07.2016 / 01:35

1 answer

4

: was missing in while and if , do so:

#encoding: utf-8
y = int(input("Ultimo número: "))
x=0
while x <= y:
   if x % 2 == 0:
     print (x)
   x=x+1

Follow doc: link

    
06.07.2016 / 01:42