Python if conditional statement error

Asked 2 years ago, Updated 2 years ago, 102 views


# # registration number=rn

rn = int (input ("Please enter the resident registration number minus (-)")
year = int(rn/100000000000)
month = int(rn/1000000000) - year*100
day = int(rn/10000000) - (int(rn/1000000000)*100)

if 21 <= year <= 99
  print("Birth year:" + str(1900+year) +"Month:" + str(month) +"Day:" + str(day))) 
elif  00 <= year <= 20
   print("Birth year:" + str (2000+year) +"Month:" + str(month) +"Day:" + str(day))) 

If you do this...


An error occurred while running.
File "/solution.py", line 10
if 21 <= year <= 99
^
SyntaxError: invalid syntax

This sort of thing.Python, I just started so I don't know... I would appreciate it if you could tell me why the error appears. ㅠ<

if문 conditional-statement

2022-09-20 20:02

1 Answers

if 21 <= year <= 99:

Beginners should also make a habit of looking at the syntax immediately preceding the syntax of the syntax error.


2022-09-20 20:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.