Multi-branch if-else statements in Python

  python-3.x

I have been looking forward to learning about If-else statements, but now I’ve gotten stuck on multi-branch ones by receiving a syntax error, although there may be other issues.

The assignment asks, "Write an if-else statement with multiple branches.
If year is 2101 or later, print "Distant future" (without quotes). Otherwise, if year is 2001 or greater, print "21st century". Otherwise, if year is 1901 or greater, print "20th century". Else (1900 or earlier), print "Long ago"."
if the user inputs 1776 they get long ago and if they put 2200, they also should get "long ago". here is where my code is at so far,

year = int(input())
if year>= 2101:
    print('Distant future')
    elif year>=2001:
    print('21st century')
    elif year>=1901:
    print('20th century')
    else:
        print('Long ago')

I received a syntax error.

Source: Python-3x Questions

LEAVE A COMMENT