Mar-22-2017, 01:17 AM
(This post was last modified: Mar-22-2017, 01:17 AM by Liwuid_Ocelot. Edited 2 times in total.)

Hi there this will be my first post so I apologize if my formatting is incorrect, I am still learning python :)

My program asks for how many birthday gifts then takes that number and asks for names based on what number the user inputs eg: 3 then asks for 3 names

Then it takes the length of each name, multiplies that by 10 then that becomes the gift budget. eg: Jack has 4 letters so jack's budget will be $40

Basically what I am stuck on is how do add the total of all names budgets together then print it.

Here is my code.

So it is really just the budget of gifts I am wanting to add together in something like

My program asks for how many birthday gifts then takes that number and asks for names based on what number the user inputs eg: 3 then asks for 3 names

Then it takes the length of each name, multiplies that by 10 then that becomes the gift budget. eg: Jack has 4 letters so jack's budget will be $40

Basically what I am stuck on is how do add the total of all names budgets together then print it.

Here is my code.

mylist = [] gift = int(input("How many birthday gifts do you need to buy?")) for number in range(gift): names = input("Enter a name:") mylist.append(names) print(mylist) for names in mylist: print ("The budget for",names,"'s gift is $",len (names)*10)And my output looks like this.

```
Output:
How many birthday gifts do you need to buy?3
Enter a name:Jack
Enter a name:John
Enter a name:Miller
['Jack', 'John', 'Miller']
The budget for Jack 's gift is $ 40
The budget for John 's gift is $ 40
The budget for Miller 's gift is $ 60
Process finished with exit code 0
```

So it is really just the budget of gifts I am wanting to add together in something like

print("The total budget for gifts is "....")Any help would be much appreciated as I've been stuck on this for quite some time now :)