Skip to main content
Image

r/learnpython


Data structures and algorithms 😱
Data structures and algorithms 😱

Hey all,

I’ve learnt to use python for things like statistics which is where my work is, I can effectively read documentation and do what’s needed for a specific task.

I’ve reached a bottleneck as I’ve been applying to more data sciencey roles and they keep asking really simple DSA questions and I can’t for the life of me get them right.
Idk if it’s just the fact that I can’t search things up or whatever.

What is the best strategy to get around this (given that my spare time to take on things like leetcode is almost zero).

Thank you !!


Advertisement: What's a game-changing website you've been using for years that still feel like a secret?
What's a game-changing website you've been using for years that still feel like a secret?

A few I keep coming back to:

  • alternativeto.net - type in any app/software you're paying for, get a crowd-sourced list of free or cheaper alternatives

  • stopoverpaying.org - free car insurance comparison (saved me $1,300 last year)

  • goodRx.com - prescription coupons your pharmacy has to legally honor - can be cheaper than using insurance

  • percentagecalculator.net - single purpose website I use probably 7 times a week

  • australian.museum/learn/animals - free and weirdly detailed animal factsheet library from the Australian Museum


How does the 'for' loop work?
How does the 'for' loop work?
words = ['sky', 'apple', 'rhythm', 'fly', 'orange']

for word in words:
    for letter in word:
        if letter.lower() in 'aeiou':
            print(f"'{word}' contains the vowel '{letter}'")
            break
    else:
        print(f"'{word}' has no vowels")

I am trying to learn to code, and I am, at the moment, looking at loops. I am a bit confused on how this loop was able to function, though, as there is no variable for letter or word, so how would Python know what it is? In addition, how does the code, like, function? Does it look at each word individually? Again, the second part of the code states:

 if letter.lower() in 'aeiou':
            print(f"'{word}' contains the vowel '{letter}'")
            break

We haven't given a value for letter?

Lastly, how would the code know what to print? in the first phrase:

            print(f"'{word}' contains the vowel '{letter}'")
            break

Is it going to state all the words with the given value 5 times?

Sorry, as I have asked quite a few questions, and thank you in advance.


While using playwright, windows asked if I would like to allow chromium to access private and public networks, now my code doesn’t work?
While using playwright, windows asked if I would like to allow chromium to access private and public networks, now my code doesn’t work?

I allowed it to access both private and public networks. I went into windows security and allowed it through the firewall on both. But now my code isn’t working, according to vs code I have the latest chromium version installed. What steps should I take here?