#๐Ÿ”’ Please tell me how to find list & average

13 messages ยท Page 1 of 1 (latest)

green cove
#

I took the information from Google Spreadsheets.

To find the average of those values

list1 = sheet.get("F2:F3")
mean = sum(list1) / len(list1)
print(mean)

I built a code called .

//

print(list1)
When I run the code
It comes out normally like [['157'], ['147']]

//

What should I do?

weary bluffBOT
#

@green cove

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

quiet tangle
#

I dont understand what you specifically need help with, can you explain more exactly?

primal forge
#

you have a list of lists with one value each, as a string. First put it in a format you can deal with, like a list of ints

spare pewter
#

you can just use something like average found in numpy
like print(numpy.average(your_list))

primal forge
#

!e

lst = [['157'], ['147']]
lst = [int(x[0]) for x in lst]
print(lst)
weary bluffBOT
#

@primal forge :white_check_mark: Your 3.12 eval job has completed with return code 0.

[157, 147]
spare pewter
#

I've no idea what the actual list is tho

#

but print(list1) will just return values that are stored in the list1 list

green cove
#

Thank you so much for your advice.

#

!close

weary bluffBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.