Python Forum
Issues with printing a variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issues with printing a variable
#1
Hi,
I am back to working on homework and I have a very simple problem that I can't seem to figure out

I am trying to print a variable as part of a string and it doenst seem to like it

# Create a program that asks the user to enter their name and their age. Print out a message addressed
# to them that tells them the year that they will turn 100 years old.

name = input ("Please enter your name: ")
age = input ("Now please enter your age: ")

num=100 - int(age)
newdate = 2017 + num


print ('You will be 100 in newdate')
If I print newdate by itself no problem, if I print the string no problem, if I print the string then new date after '' problems. And then the above problems. If I try turning the value into a string and then printing it still a problem

solved it just needed a comma. Thanks!
Reply
#2
The string formatting tutorial on our forum will be perfect help for your task.

Ah you got it solved already, great to know :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Printing a string from a variable retroC0de 1 1,754 Nov-06-2020, 11:59 PM
Last Post: timoshea

Forum Jump:

User Panel Messages

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