Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJavier Martinez
556 PointsHi, Kenneth. Can you help me with the challenge code FUNCTIONS is very hard convert lists in ints. Thanks. Javier
my_list = []
def add_list(my_list): addition = int(0) for x in len(my_list): addition = addition+ int(my_list[x]) return addition
add_list([1, 2, 3])
# add_list([1, 2, 3]) should return 6
# summarize([1, 2, 3]) should return "The sum of [1, 2, 3] is 6."
# Note: both functions will only take *one* argument each.
3 Answers
Jose Coto
11,466 PointsHi, Look at the sum function of lists. That should help you out. Example sum([here goes your list])
Javier Martinez
556 PointsThanks a lot for your time, my friend José. I'll try.
Javier.-
Javier Martinez
556 PointsThanks, José ... Here's my code:
my_list = []
def add_list(my_list): my_list = [int(x) for x in my_list] s = sum(my_list) return s
add_list([1, 2, 3])
Thanks a lot, my friend.
Have a nice Sunday.
Javier.-
Jose Coto
11,466 PointsJose Coto
11,466 PointsHi,
Look at the sum function of lists. That should help you out.