Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variables with numbers
#3
character_name = "Mark"
character_age = 50
print("There was a man called " + character_name + ", ")
print("he was " + character_age + " years old. ")
character_name = "Pete"
print("He really liked the name " + character_name + ", ")
print("but didn't like being " + character_age + ". ")
error message
Error:
C:\Users\steve\PycharmProjects\variables\venv\Scripts\python.exe C:/Users/steve/PycharmProjects/variables/variables.py There was a man called Mark, Traceback (most recent call last): File "C:/Users/steve/PycharmProjects/variables/variables.py", line 9, in <module> print("he was " + character_age + " years old. ") TypeError: can only concatenate str (not "int") to str
Reply


Messages In This Thread
Variables with numbers - by Alfie926 - Nov-11-2018, 06:48 PM
RE: Variables with numbers - by buran - Nov-11-2018, 07:00 PM
RE: Variables with numbers - by Alfie926 - Nov-11-2018, 07:38 PM
RE: Variables with numbers - by buran - Nov-11-2018, 07:52 PM
RE: Variables with numbers - by Alfie926 - Nov-11-2018, 08:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: Found input variables with inconsistent numbers of samples saoko 0 2,471 Jun-16-2022, 06:59 PM
Last Post: saoko
  Found input variables with inconsistent numbers of samples: [1000, 200] jenya56 2 2,879 Sep-15-2021, 12:48 PM
Last Post: jenya56
  Print Numbers starting at 1 vertically with separator for output numbers Pleiades 3 3,720 May-09-2019, 12:19 PM
Last Post: Pleiades

Forum Jump:

User Panel Messages

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