Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
the python idle is throwing a error at the print() function im not sure why heres the code..
password = "cow"
name = input()
input("MR PENGUIN: hello there i am Mr Penguin what is your name? ")
input("well, hello there"+name+"Tell me your password")
input("You: my password is, ")
input("MR PENGUIN: im little defh could you repeat that? ")
input("YOU: my password is, "
print("PC POLICE: STOP! dont ever trust penguins with your data becuase he just told every one that your password is "+ password)
input("Press Enter To Exit")
You are missing a parenthesis at the end of the input on the prior line.
Change:
input("YOU: my password is, "
to:
input("YOU: my password is, ")
For the record, your print was fine. Note that when you get a cryptic error, it is often something on the previous line.
This is because your input statement in the previous line is missing a closing paranthesis.
It should be:
input("YOU: my password is, ")
instead of
input("YOU: my password is, "
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
So, I'm just starting to try to learn Python and I'm following a "book" called: Automate the Boring Stuff with Python. I'm doing the first program in the book and I thought things were going just fine...but now I'm getting an error and I'm unable to figure out why.
# This Program says hello and ask for my name.
print('Hello world!')
print('What is your name?') # ask fo their name
myName = input()
print('It is good to meet you, ' + myName)
print('The length of your name is:')
print(len(myName)
print('What is your age?') # ask for thier age
myAge = input()
print('You will be ' +str(int(myAge) + 1) + ' in a year.')
VS Code shows errors starting around line 9 but I can't for the life of me figure it out. Any help would be greatly appreciated.
Thanks.
print(len(myName)
Missing ')'.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
When I try to run my code it says I have invalid syntax with my else statement, but I can't figure out what's wrong.
import random
import time
username = input("Hello. Please enter your name, then press 'enter'.
After you type something, you will need to /n"
"click the 'enter' key to send it")
print ("Hello " + username)
time.sleep(3)
game_tutorial_input = input("Do you wish to see the tutorial? (y/n)")
if game_tutorial_input == "y":
print ("Great! Press enter after each instruction to move /n"
"onto the next one.")
else
print("Are you sure? (y/n")
indent matters in python , make sure the else is on the same indent column as the if. and as stated you need a : at the end of else.. ie, else:
Try 'else:'
I believe it's missing a colon.
indent out the else
add a colon to end of the else
Explanation:
else, if, elif, with etc.. are statements which need colons after the statement
add colon after else and indentation of else is wrong
if game_tutorial_input == "y":
print ("Great! Press enter after each instruction to move /n"
"onto the next one.")
else:
print("Are you sure? (y/n")
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
My code reads:
print("Please key in a word: ",end" ")
first=input()
print("And now key in another: ",end" ")
second=input()
print("You have typed: "+first+" "+second)
but I get the result "SyntaxError: invalid syntax" and the ^ pointing to the second " following end. I am using Python 3.6, so the end notation should be correct. I have tried with and without a space between the "" after end. Can anyone see where I'm going wrong?
Keywords need to be assigned their values using =:
print("Please key in a word: ", end=" ")
first = input()
However, a better way would be to use input() directly:
first = input("Please key in a word: ")
You are missing the = sign between end and " ":
print("Please key in a word: ",end=" ")
first=input()
print("And now key in another: ",end=" ")
second=input()
print("You have typed: "+first+" "+second)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
def _main_(userInput1):
if userInput1 ==create:
userName1=input('Please enter your username : ')
password1=input('Please enter your password : ')
createAccount(userName1, password1)
else:
userName2=input('Please enter your username : ')
password2=input('Please enter your password : ')
logIn(userName2,password2)
userInput1=input('Would you like to create a account or long in, type create or login ')
_main_(userInput1)
I keep getting an error with:
'create' is not defined
Can someone help please?
If you are checking whether userInput1 is equal to the string create, you need to put create in quotes, like this: 'create', or this "create". Otherwise, Python checks if userInput1 is equal to the variable create.
You need to change if userInput1 == create to if userInput1 == "create" as when you asked the user if they wanted to create a user, the input is by default a string and so you need quotes to tell the compiler to recognize it as a string rather than it seeing create as a variable.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
So, I am trying to learn Python and am using Python 3.6.0a3 on windows 10. As part of my practice I was trying to use the "while" loop and the editor says there is an error with my code and the cursor goes to 'While True"
My code is:
#Program to practice While and Continue
While True:
Print('Who are you?')
name=input()
If name!='Joe':
continue
print('Hello Joe! What is the password? (It is a fish)')
password-input()
If password=='swordfish'
break
print('Access granted')
I can't execute it!
Here's a working example:
#Program to practice While and Continue
while True:
print('Who are you?')
name = input()
if name != 'Joe':
continue
print('Hello Joe! What is the password? (It is a fish)')
password = input()
if password == 'swordfish':
break
print('Access granted')
You had a bunch of syntax errors:
Python is case-sensitive, so if, while and print should all be in lower-case.
Conditional statements need to end with a colon :
Statements inside a conditional block need to be indented.
Further reading:
https://www.python.org/dev/peps/pep-0008/