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)
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 9 months ago.
Improve this question
def user_input():
user_input = input
name = input("enter your name ")
print("hello "+ name +"!")
print("welcome to gymbros press 1 to continue :")
if input == 1():
print("this is the personal record page where you post your best lifts ")
else:
print("thanks for using gymbros")
####################################
Im not sure what im doing wrong it keeps giving me the, TypeError: 'int' object is not callable
input() return type is str and int is not callable.
user_input is not used
It is recommended that you learn the basic syntax of Python first
name = input("enter your name ")
print("hello", name, "!")
print("welcome to gymbros press 1 to continue :")
if input() == "1":
print("this is the personal record page where you post your best lifts ")
else:
print("thanks for using gymbros")
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
This is the code:
num = int(input("Please enter your number: "))
for i in range(1,11)
print(num, "×", i ,"=", num*i)
This is the error it gives me:
File "table.py", line 3
for i in range(1,11)
^
SyntaxError: invalid syntax
This is because of loops, if-statements and some other python blocks of code require ":" at the end of the line and a tab-indented new block of code.
The correct code for your example would be:
for i in range(1,11):
print(num, "x", i, "=", num*i)
What I am talking about is:
if True:
print("In true statement")
print("The next line of indented block")
else:
print("Not in the True statement")
print("I would never get here")
The correct syntax would be:
for i in range(1,11):
print(num, "x", i, "=", num*i)
it seem like you forgot the : at the end of the for loop and the indentation in the following line.
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
I can print a string in upper case but can't get it to work when i ask the user to input a sentence. I have tried this code:
sntc = str(input ("Please enter a sentence."))
str.upper (sntc)
and this:
sntc = input ("Please enter a sentence.")
str.upper (sntc)
but none of these seem to work. Any ideas?
Python strings are immutable, so string methods like str.upper() return a new string.
So in your case, you would need to do:
upper_string = sntc.upper()
You aren't modifying the string when you use .upper() because strings are immutable. You need to assign something to what .upper() returns:
sntc = input("Please enter a sentence.")
sntc = sntc.upper()
or the shortened form:
sntc = input("Please enter a sentence.").upper()
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
I can't get the output in python with this code.
import random
die1=random.randrange(5)
die2=random.randrange(5)
total=die1+die2
input=("\nPress the ENTER key to exit.")
The black window immediately closes when opened
You are not calling input(); you are assigning a string to the name input instead.
Remove the =:
input("\nPress the ENTER key to exit.")
Over here, you are assigning input to a tuple, ("\nPress the ENTER key to exit.").
Instead, move the equals sign to before the input:
inp = input("\nPress the ENTER key to exit.")
Here is your edited code:
import random
die1=random.randrange(5)
die2=random.randrange(5)
total=die1+die2
inp = input("\nPress the ENTER key to exit.")
Now your input will be stored in the variable inp.
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, "