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 years ago.
Improve this question
Whats wrong with my If statement?
if (current_value_address == current_value['address'] and
current_input['xy'] >= current_required_value and
current_xy_amount >= MIN_AMO and
AFFL_COME > 1):
getaf_id = db.cursor()
Error:
getaf_id = db.cursor()
IndentationError: expected an indented block
If i remove the If statement it works.
You only need to indent that last part:
if (current_value_address == current_value['address'] and
current_input['xy'] >= current_required_value and
current_xy_amount >= MIN_AMO and
AFFL_COME > 1):
getaf_id = db.cursor(). #indent this line!
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 1 year ago.
Improve this question
I am currently trying to create team selection code for my python video game.
Unfortunately, it keeps highliting the ":" of my if statement and saying that it is invalid syntax, even if i change the if statement for another. I tried everything, but after all, it IS an if statement, and i can't do much.
Heres my minimal recreation of the problem. The structure is important as there is netwroking code there;
team1=[]
team2=[]
if (len(team1)+len(team2)):
if team1==team2:
rand = (random.choice([team1, team2])
if rand == "team1":
team1.append(username)
else:
team2.append(username)
else:
if team1>=team2:
team1.append(username)
else:
team2.append(username)
else:
team1.append(username)
The problem is the stray '(' you have before random.choice([team1, team2]). Delete it so it becomes:
rand = random.choice([team1, team2])
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 am learning python as 'new comer in coding'. I was writing a code and got a following error. Can someone please rectify why I have following with the code. Thank you
def mean(value):
if type(value) == dict:
the_mean=(sum(value.values()) / len(value))
else:
the_mean = sum(value) / len(value)
return the_mean
student_grades={"Marry":2,"Jim":3,"Sam":5}
print(mean(student_grades))
print(type(mean),type(sum))
The error is on line 4
You have to remove 1 indentation from the line : a python if statement is written :
def foo():
if condition:
...
else:
...
return
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
def ShowData(data = (x)):
for r in data:
print (“{:}, {:.2f}”.format(x, x))
keep getting this error:
File "<ipython-input-10-9963f96f39ca>", line 8
print (“{:}, {:.2f}”.format(x, x))
^
SyntaxError: invalid character in identifier
Replace the “ charachter with this " ?
# data is a list of lists
def ShowData(data = (x)):
for r in data:
print ("{:}, {:.2f}".format(x, x))
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's a function I'm writing:
def addError(test,range_min,range_max,result):
err = abs(log(range_max/max(range_min,epsylon))
if test >= range_min and test <= range_max:
result.append(err)
else:
e1=abs(log(test/max(range_min,epsylon)))
e2=abs(log(test/max(range_max,epsylon)))
result.append( min(e1,e2) / max(err,epsylon) *100 + err)
When I try to run this, it fails with error:
File "<ipython-input-26-8b4b5ae453e4>", line 12
if (test >= range_min and test <= range_max):
^
SyntaxError: invalid syntax
Why am I getting this?
You forgot to close all the brackets in the previous line, this should fix the problem:
err = abs(log(range_max/max(range_min,epsylon)))
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 7 years ago.
Improve this question
I am running Python 2.7.6 and when I execute the following if statement works. But if I add the commented out elif line I get a syntax error. any ideas
if output == 0:
print(Num,"is Even")
# elif output = 0:
# print(Num,"is Odd" )
else:
print (Num,"is Odd")
You want output==0 in the elif, which is comparison as opposed to output=0 (which is assignment)