0

So I’m teaching myself python online using ‘Programming with Mosh’ on Youtube. I’m looking at type conversion, and Mosh is discussing how you cannot subtract a string from an integer.

However, when I ran my program as per his tutorial, it actually works perfectly without crashing. Can anyone explain why this is happening?

This is the code I used, and according to his tutorial this should generate an error.

birth_year = input("Enter your birth year: ")
age = 2022 - birth_year
print(age)
Selcuk
  • 57,004
  • 12
  • 102
  • 110
  • What is the output you that you get after you enter your birth year? Or do you mean it doesn't crash immediately after you run the script? – Abhi_J Mar 08 '22 at 05:27
  • 2
    Are you still using Python 2 by any chance? – Selcuk Mar 08 '22 at 05:31

0 Answers0