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
a=int(input("please input number of players "))
while (a < 2):
a=int(input("please input at least two players "))
if (a==2):
p1=input("please enter name for player 1 ")
p2=input("please enter name for player 2 ")
x=float(input("please enter initiative for "+(p1)))
y=float(input("please enter initiative for "+(p2)))
x=x,p1
y=y,p2
if (x > y):
lowest=y
highest=x
elif(y > x):
lowest=x
highest=y
print(lowest)
steps=int(input("Please enter number of steps for "+(lowest)+" action" ))
i have tried everything i can think of and it needs to do this but i can't figure out how to make it work
That's exactly what the message say: in the last line, in the subexpression
"Please enter number of steps for "+(lowest)+" action"
you are trying to concatenate a string with a tuple (lowest - since it is either x or y, and both of them are tuples due to the assignment x=x,p1 and y=y,p2), which would require an implicit conversion from tuple to string.
To fix this, you have to convert explicitly the tuple to string (str(lowest)) (although I suspect that you actually want just one of the elements of the tuple to be displayed).
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 3 months ago.
Improve this question
I have to take input from the user then the operator has to print what number is before the input and after the input like:
input= 3
has to print 2 and 4
I used range, did I do it wrong? I am just a beginner in Python.
number=int(input)
for num in range(number ,+ 1, -1):
print(num)
You first need to use input() to let the user register a number.
Then, simply print the number with number - 1 and number + 1.
number = int(input("What is your number? "))
print(f"{number - 1} {number + 1}")
Outputs to:
What is your number? 3
2 4
you don't need range do this task
num = int(input())
print(num-1, num+1)
Other answers which say that you don't require a loop are perfectly fine, however I want to add a little suggestion in case you need to print more than just the number before and after. Maybe (as your first implementation suggests) you want to print the 5 numbers before and after. In this case you can do:
R = 5 #range
N = int(input("Enter your number. "))
numbers = [ i for i in range(N-R,N+R+1) if i != N]
print(numbers)
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
Check out the screenshot and help this newb with why i'm getting this syntax error with the for loop even though im following the right syntax.
The code :
elif choice == 'AVERAGE':
import statistics
lst = []
n = int(input('Enter number of values to calculate mean of: ')
for i in range(0,n):
ele=int(input())
lst.append(ele)
The Error : Invalid Syntax for the ':' after 'range(0,n)'
You are spacing the items inside the for loop with double Tab, the indentation should be either 4 spaces or a single tab.
And you are missing a parenthesis closing in the n input line
See the modified code below.
elif choice == 'AVERAGE':
import statistics
lst = []
n = int(input('Enter number of values to calculate mean of: '))
for i in range(0,n):
ele=int(input())
lst.append(ele)
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
Here is my code:
while True:
try:
input1 = int(input("Please type the number: "))
print("Ok!")
except ValueError:
print("Please type it again")
else:
break
for i in range(input1):
print(input1)
This is what i want it to be:
Please type the number: 4
Ok!
0
1
2
3
This is what it gave me:
Please type the number: 4
Ok!
4
4
4
4
Please give me some advice
The mistake is here:
for i in range(input1):
print(input1)
It will always print the upper limit of the interval, which is 4.
Try:
for i in range(input1):
print(i)
and see how it goes.
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
I'm trying to write a program that calculates BMI by asking what one's weight (in kilograms) and height (in meters) is. Why am I getting an invalid syntax error here?
units = input("What units would you like to use? Enter I for Imperial or M for Metric")
weight = input(int("what's your weight?")
height = input(int("what's your height?")
enter image description here
You've picked the wrong order. You should be having int(input()) not the input(int())
And also you have less ) than you should be. Check that for every opening bracket there is a closing one
You have the wrong order of int and input and did forget the closing parenthesis:
units = input("What units would you like to use? Enter I for Imperial or M
for Metric")
weight = int(input("what's your weight?"))
height = int(input("what's your height?"))
Avoid using input() and use raw_input() instead. You also put int() in the wrong place.
Your code should look something like this:
units = raw_input('What units would you like to use?....')
weight = int(raw_input("what's your weight?"))
height = int(raw_input("what's your height?"))
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
print("Hello. Please Proceed to Enter a Range of Numbers")
first = int(input("please enter the first number in the range: "))
last = int(input("please enter the last number in the range: "))
numlist=list(range(first,last)
I get an error expected eof while parsing. When I add in print(numlist)
it adds an additional error.
print("Hello. Please Proceed to Enter a Range of Numbers")
first = int(input("please enter the first number in the range: "))
last = int(input("please enter the last number in the range: "))
numlist=list(range(first,last)) #FTFY
for x in numlist:
print(x)
Essentially what this does is after numlist is declared, it traverses it and prints out every value on a new line
Your main problem was that you were missing the second RPAREN on the numlist declaration