1

I am trying to use this function

class AClass(cls):
    def add_entry(self):
        year = input('Please enter the movie in which entry was made: ')
        if not isinstance(year, int) or year < 1900 or year > 2021:
            raise ValueError('Please enter a valid year between 1900 and 2021')
        else:
            return year

However when I input any year, for example: 1980 I get the value error. Please suggest how to rectify this.

MAL
  • 29
  • 4
  • 2
    The issue is with `isinstance(year, int)`, which is false since the year is read as a string. – GoodDeeds Apr 26 '21 at 02:34
  • I added int infront of input and it seems to be working: year = int(input('Please enter the movie in which entry was made: ')) – MAL Apr 26 '21 at 03:01

0 Answers0