r/learnpython • • 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

324 comments sorted by

View all comments

Show parent comments

2

u/Nythious Feb 20 '21

There's a very sexy way to do this if you convert those lists into sets but if you're destined to using lists then you'll want to switch out "if list1 blah in list 2" with "if element....". That's my hint for you. Edit: on my phone, sorry about terrible formatting!

2

u/Athenas-Helm Feb 20 '21
common_list = []      
    for element in list1:          
        if element in list2:              
            common_list.append(element)             
        else:              
            continue  
return(common_list)

1

u/Athenas-Helm Feb 20 '21

The append(element) syntax might not be right but the concept is what i'm trying to grasp generally lol

EDIT: thank you for the advice!