![]() |
|
[Python] What am I doing wrong? - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Python (https://sinister.li/Forum-Python) +--- Thread: [Python] What am I doing wrong? (/Thread-Python-What-am-I-doing-wrong) Pages:
1
2
|
[Python] What am I doing wrong? - par†ian - 03-18-2013 Hey guys, I need some help so I came to the best ![]() I am currently doing an online course for Python (reccomended) and I am stuck on this question, I tried everything, I may be missing something but anyways Here is the question: For now, replace the ___s with the form of % you need to complete your quest: %s inside the string, and % to link the string with its arguments. Answer the questions in the console as they pop up! Default code: Code: name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")
print "Ah, so your name is ___, your quest is ___, " \
"and your favorite color is ___." ___ (name, quest, color)Here is what my answer is: Code: name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")
print "Ah, so your name is "%s" % (name), your quest is,
print "%s" % (quest), and your favorite color is,
print "%s" % (color)." print "%s" % ("name", "quest", "color")RE: [Python] What am I doing wrong? - H4R0015K - 03-18-2013 Correct code.ask what you dont understand. Quote:name = raw_input("What is your name?") RE: [Python] What am I doing wrong? - Ex094 - 03-18-2013 I've edited your code: Code: name = input("What is your name?")
quest = input("What is your quest?")
color = input("What is your favorite color?")
print ('Ah, so your name is %s, your quest is %s, and your favorite color is %s' % (name, quest, color))Mistakes: 1) You should have done (name, quest, color) instead of this ("name", "quest", "color") because they have the stored values and you are making them separate strings. 2) Use %s and % like this: Code: name = input('Your Name: ')
print('My name is %s' % (name)')RE: [Python] What am I doing wrong? - par†ian - 03-18-2013 (03-18-2013, 05:35 AM)Ex094 Wrote: I've edited your code: Thanks dude, appreciate it, all I am getting back is Code: What is your name?>RE: [Python] What am I doing wrong? - H4R0015K - 03-18-2013 (03-18-2013, 05:57 AM)partian Wrote:(03-18-2013, 05:35 AM)Ex094 Wrote: I've edited your code: thats because the above code is for python 3.x and you are using python 2.7 RE: [Python] What am I doing wrong? - par†ian - 03-18-2013 (03-18-2013, 06:03 AM)H4R0015K Wrote: ts because the above code is for python 3.x and you are using python 2.7 Ahh, I'm just doing a course that's all - just working with the tools I'm given. Could you possibly fix it for me ![]() for 2.7 that is. RE: [Python] What am I doing wrong? - H4R0015K - 03-18-2013 (03-18-2013, 06:08 AM)partian Wrote:(03-18-2013, 06:03 AM)H4R0015K Wrote: ts because the above code is for python 3.x and you are using python 2.7 look above i have posted the code for 2.7 RE: [Python] What am I doing wrong? - par†ian - 03-18-2013 (03-18-2013, 06:12 AM)H4R0015K Wrote: look above i have posted the code for 2.7I used the edited code above: Code: name = input("What is your name?")
quest = input("What is your quest?")
color = input("What is your favorite color?")
print ('Ah, so your name is %s, your quest is %s, and your favorite color is %s' % (name, quest, color))but it's still giving me the same message. Code: What is your name?>RE: [Python] What am I doing wrong? - H4R0015K - 03-18-2013 (03-18-2013, 06:14 AM)partian Wrote:(03-18-2013, 06:12 AM)H4R0015K Wrote: look above i have posted the code for 2.7I used the edited code above: i am talking about this one. Quote:name = raw_input("What is your name?") RE: [Python] What am I doing wrong? - par†ian - 03-18-2013 (03-18-2013, 06:17 AM)H4R0015K Wrote: i am talking about this one.Still gives me the same message :S :headbash: |