Help with Python variables

fallenapples

In Runtime
Messages
386
Location
Toronto, Ontario
My course code assigned me this exercise and when I run it in cmd I get TypeError: unsupported operand and type(s) for % 'Nontype' and 'str'
in line 9.

Here is my code:
Code:
my_name = 'Zed A. Shaw'
my_age = 35
my_height = 74 #inches
my_weight = 180 #lbs
my_eyes = 'Blue'
my_teeth = 'White'
my_hair ='Brown'

print ("Let's talk about %") % my_name
 
I believe

print ("Let's talk about %") % my_name

should be

print ("Let's talk about %r" % my_name )

EDIT: Or maybe
print ("Let's talk about %r") % my_name

I'm no Python guru. never actually coded in it :tongue:
 
Thanks a lot. It's a bit confusing because the author does not use any parenthesis for any of his print statements. I guess it's because I'm on using a newer Python.
 
Thanks a lot. It's a bit confusing because the author does not use any parenthesis for any of his print statements. I guess it's because I'm on using a newer Python.

I hate when people don't use parentheses in function calls if they're optional.

People at work do that with VB.NET all the time...irritates me when I have to read through/edit it because then they just look like variables instead of function calls lol.
 
Now if I want to bring in multiple strings, how can I do that? The authors statement is as follows,

Code:
print "He's got %s eyes and %s hair." % (my_eyes, my_hair)
 
Back
Top Bottom