A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
I am working on the "while" function in Lecture 2. When I type "print y" (without the quotes), I get a syntax error. Does anyone know why?
anonymous
 5 years ago
I am working on the "while" function in Lecture 2. When I type "print y" (without the quotes), I get a syntax error. Does anyone know why?

This Question is Closed

Owlfred
 5 years ago
Best ResponseYou've already chosen the best response.0Hoot! You just asked your first question! Hang tight while I find people to answer it for you. You can thank people who give you good answers by clicking the 'Good Answer' button on the right!

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0can you please put the rest of the while loop and I'll try to answer

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0>>> y=0 >>> x=3 >>> itersLeft = x >>> while(itersLeft>0): y=y+x itersLeft=itersLeft1 print y SyntaxError: invalid syntax

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I think because you haven't indented it correctly. the line y = y + x should be tabbed in also the next one

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Hmm. on my screen in Python, those two lines are indented, but after copying them into the chat box, they are no longer indented...

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I'm not sure, when I run it, it comes up with 9

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0That's strange. I guess I'll just keep trying. Thanks for your help Joz!

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0are you sure they are not in line with while? I'm just saying, because the print y is further left on the chat box

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0in my python interface, "y=y+x" and "itersLeft = itersLeft  1" are both indented to the right of the "while" statement. "print y" is to the left of the while statement

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0yeah, that sounds right to me. When it comes up with the error, is there a pink thing on the script part?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0This is basically my first time programming, so I'm not exactly sure what you mean by script. "print" is highlighted in pink, and below that it says "SyntaxError: invalid syntax"

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0hmmm... try lining it all on the left hand side, except the 2 lines under while. Failing that, I don't know.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ok i'll give that a shot. my last question for you  how do i line everything up on the left side? every type i start a line, it starts with ">>>"

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0wait... are you doing it straight into the shell?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0try to find the IDLE page. give me a minute and I'll tell you the path to find it...

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0well, i feel like an idiot. As I was watching the video lecture, I noticed my screen looked different, but I ignored it. You're right, the top of my screen says "Python Shell"

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0is it a white screen, yeah? (Don't worry, I did the same)

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0just go to file, new window. If you don't have an option bar on the top, let me know

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ahh  that gave me a blank screen. i typed in the code, saved, and clicked "run module" and that gave me the right output for y (9). Thank you so much for walking me through this

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Haha no worries, you are set up now...

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0also make sure when you save, you save as name.py

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ok got it. thanks again...
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.