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
Hugo Jeffreys
Python Web Development Techdegree Student 1,738 PointsAlternatives to Combo challenge using enumerate
Though I've actually done this task now, it took me a looong time and I thought I'd go through a few other variations. When I started looking for a solution using 'enumerate' I hit a rut though. Can anyone tell me why this isn't working (syntax error at the .format). Many thanks!!
def combo(a,b):
tuple_list = []
b = list(enumerate(b))
position = 0
for i in list(enumerate(a)):
tuple_list += "{}:{}".format.(i,b[position])
position += 1
print (tuple_list)
MOD: I formatted your code to make it easier for everyone to read. Thanks for posting! (See the Markdown Cheatsheet below the question textbox to see how to format code. Don't worry, it's easy! :-))
1 Answer
mhjp
20,372 PointsThe error is from the extra . you have after format.
tuple_list += "{}:{}".format.(i,b[position])
^
Hugo Jeffreys
Python Web Development Techdegree Student 1,738 PointsHugo Jeffreys
Python Web Development Techdegree Student 1,738 PointsAaaaah. Need to get my eyes checked!! Thanks so much!