A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
Hi i am wondering what i did wrong here
def ask() :
answer = raw input("Do you wish to tell me about your favorite desert?")
If (answer == 'yes' ) : print ("Next i will ask you about your favorite desert")
Print ("now i will tell you about your clasess favorite desert")
anonymous
 5 years ago
Hi i am wondering what i did wrong here def ask() : answer = raw input("Do you wish to tell me about your favorite desert?") If (answer == 'yes' ) : print ("Next i will ask you about your favorite desert") Print ("now i will tell you about your clasess favorite desert")

This Question is Closed

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0you have a few syntax errors, raw input has to be raw_input, you can not capitalize if or print.

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0you can see syntax errors when you try and run the program, they should highlight in red, and as you fix each error it will point out another.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0i have a syntax error that im not sure how to resolve If (answer == 'yes' ) : print ("Next i will ask you about your favorite desert") The colon is the line is having a syntax problem and im not sure what is wrong, thanks

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0the i is capitalized in if

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0yeah it is, but im getting a snytax eorr on the colon

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0where it points unfortunately is not always 100% accurate, its close but the error may be somewhere else on that line or even another place entirely, python is case sensitive.

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0so it will not recognize If,Else,Return it will recognize if, else, return

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ok i fixed the syntax, now when i go to run the module it will run and nothing happens (im a beginner)

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0im not sure if i just need to add something to the end of the script,

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0so now you have a working program. cool but what you have written so far is a function. A function will not do anything unless you have called it somewhere. you can simply call it by typing ask() anywhere after the function has been defined. So you can not call ask() before you have defined the function ask(), later on in this course there are instances where a function will call itself within itself. Dont worry about that yet.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0>>> >>> ask () Do you wish to tell me about your favorite desert?yes Next i will ask you about your favorite desert Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> ask () File "C:\Python25\fixedhw.py", line 4, in ask Print ("now i will tell you about your clasess favorite desert") NameError: global name 'Print' is not defined This is the error im getting when i call the function

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0its another syntax error, try and find out what it is, and if you still need help let me know

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ok i found it, thank you very much youv been a great help, now im wondering about this, i am trying to mkae the program do=that asks the user whether they wish to tell which is their favorite dessert, or they wish to find out what other's favorite dessert is. Now when i do that i prints both the lines at the end regardless if they say yes or no, so im wondering how to seprate them and make it only print depending on the awnser the user gives.

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0take a look at this. http://docs.python.org/tutorial/controlflow.html

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ok perfect, thanik you very much. i might be back with more questions :) but thanks for now
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.