Python Forum
adding parts of a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
adding parts of a list
#2
you can use list comprehension
scores = [int(score) for score in data[1:]]
or map
scores = map(int, data[1:5])
then

grade = sum(scores)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
adding parts of a list - by Eric7Giants - Nov-16-2019, 08:40 PM
RE: adding parts of a list - by buran - Nov-17-2019, 08:37 AM
RE: adding parts of a list - by ichabod801 - Nov-17-2019, 02:35 PM
RE: adding parts of a list - by Eric7Giants - Nov-17-2019, 04:37 PM
RE: adding parts of a list - by buran - Nov-17-2019, 05:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  help with adding duplicates elements together in a list 2ECC3O 5 3,507 Sep-10-2022, 07:11 AM
Last Post: 2ECC3O
  Python Adding +1 to a list item cointained in a dict ElReyZero 1 2,709 Apr-30-2020, 05:12 AM
Last Post: deanhystad
  Adding values to list and pickling mefiak 2 3,546 May-31-2018, 08:57 AM
Last Post: mefiak
  adding a number to the list atux_null 4 4,969 Nov-06-2017, 07:01 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020