- 1

error pyhton code

#python 2.7.6 import random x = random.randint(0,100) if x > 53 print('You Won!') elif x <= 53 print('You Lost.') elif x == 53 print('Drow.') exit() output: File"source_file.py", line 7 if x > 53 SyntaxError:^invalid syntax

3rd Oct 2016, 7:30 AM
Alex Silin
Alex Silin - avatar
4 odpowiedzi
+ 2
A colon is missing after if statement. if condition: statements elif condition: statements else: statements
3rd Oct 2016, 7:56 AM
Hemanth Kumar Kachadimangalam Ramakrishnan
Hemanth Kumar Kachadimangalam Ramakrishnan - avatar
+ 1
thank you
3rd Oct 2016, 8:11 AM
Alex Silin
Alex Silin - avatar
+ 1
in elif you have =. You don't need second elif or =< in first elif. if x > 53: statements elif x < 53: statements else: statements
3rd Oct 2016, 8:33 AM
Den Kologrivko
Den Kologrivko - avatar
+ 1
import random x = random.randint(0,100) if condition: print('You Won!') elif condition: print('You Lost.') else: print('Drow.') exit() output: file"source_file.py" line 8 print('You Won!') ^ indetation error: expected an indented block
3rd Oct 2016, 8:46 AM
Alex Silin
Alex Silin - avatar