Function not changing array [closed] - python

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()

Related

SyntaxError File "import.py", line 14 [closed]

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

A python syntax error that cannot find and answer [closed]

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():

Python Error "length is not defined" [closed]

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

Error with function returning string [closed]

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))))
^

Eulers method- velocity and position as a function of time for runner [closed]

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
Acceleration in a given point is given by a=5-0.004364*v^2
I want to store all the values of v and x and a in lists so that I later can plot them as a function of time. Keep in mind I'm a beginner. This is my code so far:
x_val=0
x=[]
x.append(x_val)
v_val=0
v=[]
v.append(v_val)
a_val=5.0
a=[]
a.append(a_val)
h=0.1
while x_val <=100:
v_val += (a_val*h)
x_val += (v_val*h)
a_val=(5-0.004364*(v_val**2)
a.append(a_val)
v.append(v_val)
x.append(x_val)
I'm getting a syntax error on "a.append(a_val)": invalid syntax
What am I doing wrong here? Please help
There is closed parenthesis missing in the below line
`a_val=(5-0.004364*(v_val**2)`

Categories