Python Forum
why is this variable not printing out properly?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why is this variable not printing out properly?
#2
(Dec-27-2016, 07:00 AM)dursland Wrote: When I change the variable to a string the line executes properly.
That is exactly it.  You can't concatenate a string and int.

The recommended way would be to use format.  String concatenation in general is not a great technique (though often the first thing taught >.>)

var1 = 2 + 2
 
print('The result of all calculations is {} and we are done.'.format(var1))
Reply


Messages In This Thread
RE: why is this variable not printing out properly? - by Mekire - Dec-27-2016, 07:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Printing the variable from defined function jws 7 1,543 Sep-03-2023, 03:22 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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