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 division_title(initial):
n = initial.split()
if len(n) == 3 :
return n
else return [n[0],None,n[1]]
SyntaxError: invalid syntax
error message
You need to write it as follows.
def division_title(initial):
n = initial.split()
if len(n) == 3:
return n
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
ddx = []
def AGMA(): #anion gap metabolic acidosis
ddx = ["Methanol", "Uremia", "Diabetic Ketoacidosis", "Paraldehyde", "Iron tablets", "Isoniazid", "Lactic acidosis", "Ethanol", "Salicylates (aspirin) - Late"]
return ddx
print(ddx)
print(ddx) is just returning [] still
How do I get my function to actually change to the array I want?
You need to pass the return value to the variable
ddx = AGMA()
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 calculate_money_made(**trips):
total_money_made = 0
for trip_id, trip from trips.items():
trip_revenue = trip.cost - trip.driver.cost
total_money_made += trip_revenue
return total_money_made
gives an error! cannot figure out
File "script.py", line 41
for trip_id, trip from trips.items():
^
SyntaxError: invalid syntax
Change "from" to "in"
for trip_id, trip in trip.items():
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 infPi(num):
pi = 0
for i in range(num):
pi += (1/((2(i+1)-1)**2)
print(pi*4)
The syntax error is for the line with "Print(pi*4)"
There was a parenthesis missing at the end and a syntax error in the 4th line ( pi += (1/(2*(i+1)-1)**2) ) , try like this:
def infPi(num):
pi = 0
for i in range(num):
pi += (1/(2*(i+1)-1)**2)
print(pi*4)
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
Please help me fix this code! When I run it it says that "length is not defined"
word1 = "sesquipedalian"
word2 = "sesquiannual"
length_of_word1 = length(word1)
length_of_word2 = length(word2)
test_number = 4298374272384726348726348726348234
if length_of_word1>length_of_word2:
test_number += length_of_word1%3
else:
test_number -= length_of_word1%3
print test_number
The Python function is len not length
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 need help with a cryptic error message with python:
def format1(arg1,arg2,arg3,bf):
yu = 0
if(bf):
yu = concat(concat("Back: [",numtostr(arg1)),concat("]: ",concat(arg2,concat(" -- ",arg3))))
else:
yu = concat(concat("Forward: [",numtostr(arg1),concat("]: ",concat(arg2,concat(" -- ",arg3))))
return yu
result:
File "testdirectoryscroll2.py", line 27
return yu
^
??? :D
There is a missing closing parenthesis in the previous line:
yu = concat(concat("Forward: [",numtostr(arg1)),concat("]: ",concat(arg2,concat(" -- ",arg3))))
^