-4
Name = input("What is your Name?")
Hobby = input("What is your Hobby
Color = input("What is your favorite Color?")

print ("Ah, so your Name is %s, your Hobby is %s, ") \
("and your favorite Color is %s. " % (Name, Hobby, Color) 

Hi Guys! I have started coding a few days ago and was going to do a query code.

Now... my problem is that this code doesn't work. I have tested a few things why it doesn't but I can't find the error.

When I run it an error message appears :

Traceback (most recent call last):
  File "/Users/master/Documents/Untitled3.py", line 6, in <module>
    ("and your favorite Color is %s.") (Name,Hobby,Color)
TypeError: 'NoneType' object is not callable
amanb
  • 4,209
  • 2
  • 14
  • 34
Constantin
  • 23
  • 7

3 Answers3

0

You are trying to call the result of the print statement:

result_of_print = print("Ah, so your Name is %s, your Hobby is %s, ")
result_of_print("and your favorite Color is %s. " % (Name, Hobby, Color))

but result_of_print is None.

Correct the parentheses:

print("Ah, so your Name is %s, your Hobby is %s, "
    "and your favorite Color is %s. " % (Name, Hobby, Color))
Daniel
  • 39,063
  • 4
  • 50
  • 76
0

The problem it is you are closing the pirnt function

print ("Ah, so your Name is %s, your Hobby is %s, ")(just here) \ ("and your favorite Color is %s. " % (Name, Hobby, Color)

You can do print ("Ah, so your Name is %s, your Hobby is %s, "+ "and your favorite Color is %s. " % (Name, Hobby, Color))

juancarlos
  • 524
  • 3
  • 9
-1

Here is the full working code : the format you've used is incorrect for printing .

Name = input("What is your Name?")
Hobby = input("What is your Hobby")
Color = input("What is your favorite Color?")

print ("Ah, so your Name is %s, your Hobby is %s,and your favorite Color is %s. " % (Name, Hobby, Color))

Alternatively I will suggest you to use string.format it is much easier to use atleast i think so.

print ("Ah, so your Name is {0}, your Hobby is {1},and your favorite Color is {2} .".format(Name, Hobby, Color))

Output :

What is your Name?toheed
What is your Hobbycricket
What is your favorite Color?blue
Ah, so your Name is toheed, your Hobby is cricket,and your favorite Color is blue. 
toheedNiaz
  • 1,395
  • 1
  • 10
  • 13
  • so {0} is the same as %s? – Constantin Apr 14 '18 at 17:04
  • Yes it is exactly same – toheedNiaz Apr 14 '18 at 17:05
  • 1
    ("foo: %s" % str_value) is equivalent to ("foo: {0}".format(str_value)) – raul.vila Apr 14 '18 at 17:06
  • Yes. That wasnt it but that doesnt matter - i have another question: Name = input("What is your name?") Hobby = input("What is your Hobby?") Color = input("What is your favorite Color?") print("Ah, so your Name is %s, your Hobby is %s, " "and your favorite Color is %s. " % (Name, Hobby, Color)) print("How old are you?") input("Type your age here:") I want to calculate the date of birth by their age and the date right now(2018). I need to calculate 2018 - the age of the person. How do I do that? I just cant get it right lol. – Constantin Apr 14 '18 at 18:10
  • @Constantin you can always put it ask a new question . we can help you with that as well :) – toheedNiaz Apr 14 '18 at 18:19
  • @toheedNiaz I just did... just needed to wait 1 1/2 for another question – Constantin Apr 14 '18 at 18:19