Python Forum
How to add items within a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add items within a list
#1
I need to make a program which take all the numbers that has been inputted and add them all up.
I know how to place the inputted number into a list. I just don't understand how to add them up while in the list format.
This is my current code
expenses = input('Enter the expenses: ')
listexpenses = expenses.split()


print('Total: $' + )
I don't know where to go from here.

Thanks
Reply
#2
The built in sum() function is all you need here.
Reply
#3
(Nov-01-2018, 09:53 AM)j.crater Wrote: The built in sum() function is all you need here.
Ahh, I see thanks.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Collisions for items in a list Idents 3 2,293 Apr-06-2021, 03:48 PM
Last Post: deanhystad
  Removing items in a list cap510 3 2,345 Nov-01-2020, 09:53 PM
Last Post: cap510
  Help with Recursive solution,list items gianniskampanakis 8 3,577 Feb-28-2020, 03:36 PM
Last Post: gianniskampanakis
  Removing items from list slackerman73 8 4,421 Dec-13-2019, 05:39 PM
Last Post: Clunk_Head
  Find 'greater than' items in list johneven 2 4,464 Apr-05-2019, 07:22 AM
Last Post: perfringo
  How to keep duplicates and remove all other items in list? student8 1 4,943 Oct-28-2017, 05:52 AM
Last Post: heiner55
  Help printing any items that contains a keyword from a list Liquid_Ocelot 13 73,322 May-06-2017, 10:41 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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