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 trial

Python Python Basics (Retired) Putting the "Fun" Back in "Function" Functions

Javier Martinez
Javier Martinez
556 Points

Hi, 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])

functions.py
# 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.

Hi,

Look at the sum function of lists. That should help you out.

3 Answers

Hi, Look at the sum function of lists. That should help you out. Example sum([here goes your list])

Javier Martinez
Javier Martinez
556 Points

Thanks a lot for your time, my friend José. I'll try.

Javier.-

Javier Martinez
Javier Martinez
556 Points

Thanks, 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.-