Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How to plus a list of numbers which is an input in python?

I have this challenge in Grok Learning where the challenge asks you to take a list of numbers as an input from the user and return the program with the total of all the numbers listed

Example

Input: Enter Number:

User: 10,12,13

Total: 35

I know that you can split up the list using the .split() function but I don't know how to plus all the numbers together.

Help me create the program thank. Here's the screenshot of the challenge

Update:

I meant to say thanks

Attachment image

2 Answers

Relevance
  • 6 years ago
    Favorite Answer

    Hi bashu. How about this Python 3 code:

    #!/usr/bin/python

    #ListAdd.py

    #Python 3.4

    num_str = input('Enter Numbers: ').split(' ')

    total = 0

    for n in num_str:

    ... total += int(n)

    print ('Total:', total)

    #Note: I've used "... " to indicate a tab character (which Y! Answers removes).

  • 6 years ago

    Hi Bashu,

    Please stop putting our questions online. If you're really stuck, you can send us a question via the 'enquiries' button on the site and we'll give you a hint.

Still have questions? Get your answers by asking now.