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
Nikolay Nogin
22,154 PointsCan you help me to make a better code?
I can't understand, how can I clear the first list (my_list) and use it to add my tuples there, instead of creating a new empty list (my_list2)? Please help if you know...
This code works, but when i delete my_list2 and clear() my_list, it returns a lot of unusual stuff..
def combo (*args):
my_list = []
my_list2 = []
my_tuple = None
count = 0
while True:
try:
for num in args:
my_list.append(num[count])
my_tuple = tuple(my_list)
my_list2.append(my_tuple)
my_list.clear()
count+=1
except IndexError:
break
print(my_list2)
3 Answers
Zachary Kaufman
1,463 PointsWhat challenge is this for?
Zachary Kaufman
1,463 PointsI'm actually working on the same challenge right now and am stumped... if I get a solution I will bring it here.
Nikolay Nogin
22,154 PointsOokey, thanks :)
Zachary Kaufman
1,463 Pointshttps://teamtreehouse.com/community/stuck-on-this-one-5
check out this post, it helped me pass it. The one thing I do not understand about the solution (Which works by the way...) is why he included a , at the end of the line that starts with
output +=
if you can figure that out can you let me know?
Nikolay Nogin
22,154 PointsYes, a lot of information there, thanks, but i have already passed it, I just wanted to simplify my code.
Nikolay Nogin
22,154 PointsNikolay Nogin
22,154 PointsIt's last challenge in Python collectons in Tuples, named combo. Sorry, I don't know how to make tags...