Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sum of List
#1
Hi,

I have wrote a python program to sum the numbers in a list.However its giving answer one.

Please advise.

MyList = []
Number =  int(input("Please enter number:"))
for i in range(1, Number + 1):  
    value = int(input("Enter Numbers %d:" %i))
MyList.append(value)

total = sum(MyList)

print("Sum of num:", total)
output

[C:\Practice>py Sumlist.py
Please enter number:4
Enter Numbers 1:1
Enter Numbers 2:2
Enter Numbers 3:3
Enter Numbers 4:1
Sum of num: 1
Reply


Messages In This Thread
Sum of List - by nag_sathi - Jul-07-2019, 04:32 PM
RE: Sum of List - by SheeppOSU - Jul-07-2019, 04:33 PM
RE: Sum of List - by DeaD_EyE - Jul-07-2019, 05:09 PM
RE: Sum of List - by Yoriz - Jul-07-2019, 04:36 PM
RE: Sum of List - by nag_sathi - Jul-08-2019, 05:19 AM
RE: Sum of List - by Yoriz - Jul-08-2019, 05:27 AM
RE: Sum of List - by perfringo - Jul-08-2019, 06:53 AM

Forum Jump:

User Panel Messages

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