# Newbie to coding trying to use list item as argument in a function browsing

• posted
0

Sorry for likely simple questions but cant seem to find the answers and the group was awesome with my last simple question. Amazing how much time can be spent looking for answer. Ive certainly spent plenty on this one. Learned a lot in the process of looking but cant find my specific answer

I just have a simple list and want to use an individual item from the list as an arguement in a function when I call the function.

Error is “list() takes at most 1 argument (6 given)

I have tried many variations of this trying to get it correct. Below I have pasted current form of code.

Abbreviated Code below (weight_lbs and ideal_body_wt are calculated by other functions assigned to a variable and passed to this function):

percent = list(40, 50, 55, 60, 70, 80)

def Weight_After_PercentageEWL(percent, weight_lbs, ideal_body_wt):
x = weight_lbs - (percent * ideal_body_wt)
weight_after_percentewl = Weight_After_PercentageEWL(percent, weight_lbs, ideal_body_wt)

print('With Sleeve Gastrectomy patients lose between 40% and 60% Excess Weight Loss. This would put your weight between ' + str(Weight_After_PercentageEWL(percent, weight_lbs, ideal_body_wt)) + ' and ' + str(Weight_After_PercentageEWL(percent , weight_lbs, ideal_body_wt)))

• posted
0

@danaportenier, list init needs a list, not several values. Thus you could say:

``````percent = list([40, 50, 55, 60, 70, 80])
``````

But this is just redundant (giving a list to `list` to create a list), so this is sufficient:

``````percent = [40, 50, 55, 60, 70, 80]
``````

A reminder on the best practices when getting advice from the forum:

• Enclose code into three back-ticks (select code, then click the `</>` above the edit field)

• Share also at least the line number of the error, or preferably the whole stack trace

• posted
0

Yes I used that option but was cycling through different option I found to try to be able to call an individual item in my print statement below. Thanks

Internal error.

Oops! Looks like something went wrong!