Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What have I done wrong?
#1
So I am new to learning Phyton and I don't know what I did wrong here, I would appreciate it if you could help me and also if you could simplify your explanation a bit.

This is the code:

birthyear = input(' in what year were you born? ')
age = 2019 - int(birthyear)
print(' you are ' + age + ' years old. ')
And this is the error I get:

Error:
Traceback (most recent call last): File "C:/Users/alicf/PycharmProjects/NOOB/yildan yas hesabi/erdo.py", line 3, in <module> print(' you are ' + age + ' years old. ') TypeError: can only concatenate str (not "int") to str
Reply


Messages In This Thread
What have I done wrong? - by Gandalf - Sep-23-2019, 01:22 AM
RE: What have I done wrong? - by micseydel - Sep-23-2019, 01:29 AM
RE: What have I done wrong? - by Gandalf - Sep-23-2019, 02:07 AM
RE: What have I done wrong? - by perfringo - Sep-23-2019, 02:44 AM
RE: What have I done wrong? - by Gandalf - Sep-23-2019, 03:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,680 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  python gives wrong string length and wrong character thienson30 2 3,062 Oct-15-2019, 08:54 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020