r/learnpython • u/Nythious • Feb 20 '21
What are you having difficulty learning or are currently struggling to learn?
I'm curious what the community here has difficulty with when it comes to learning Python. Partly because I want to see if the more experienced community here (or myself) can help point you into the right direction. . . but also because I'm trying to come up with video tutorial ideas for future content and would love to hear from Python learners what would be most useful to dedicate our time on.
I'm looking forward to hearing what you guys have to say!
417
Upvotes
2
u/keraj93 Feb 20 '21
I assume that the code is a part of a function, otherwise, the return statement will cause an error
if you iterate directly over the elements with
for element in list1then you don't need theindexor. You can use the ´elementto check the if statement, like this:if element in list2:and common_list.append(element).Also a shortcut:
intersection = list(set.intersection(set(list1), set(list2)))`