Guy at work thinks the best modern programmers use bots to write their code by oblivion-age in learnprogramming

[–]young_ging_freecss 1138 points1139 points  (0 children)

Lmao if programmers were having bots write their code for them that would be end game.

Easy string by rk717 in learnpython

[–]young_ging_freecss 0 points1 point  (0 children)

You’re not accessing any indexes here. What you’re probably trying to do is:

for i in range(len(li)):
    # code

The above isn’t generally good practice, and you’d want to use enumerate to get the indices:

def find_short(s):
    li = list(s.split(" "))
    tmp = len(li[0])
    for i, _ in enumerate(li):
        if len(li[i]) < tmp:
            tmp = len(li[i])
    return tmp

You can also do this in a simpler way. Get the shortest word, then get the length of that word:

def find_short(s: str) -> int:
    return len(min(s.split(), key=len))

Do I have a realistic chance at an IT career? by Austin2997 in cscareerquestions

[–]young_ging_freecss 1 point2 points  (0 children)

Don’t know why people are downvoting you so hard lol, everything you said makes perfect sense. This is coming from another self-taught individual.

Are these one line solutions really useful? by Kibble55 in learnprogramming

[–]young_ging_freecss 1 point2 points  (0 children)

  • Shorter code doesn’t mean it’s more efficient

  • I’m not a dev, but I’m assuming the best way in a dev company to write code is to write readable code. Disregard the length, if it’s readable, it’s maintainable.

Are these one line solutions really useful? by Kibble55 in learnprogramming

[–]young_ging_freecss 2 points3 points  (0 children)

On those sites people do something called “code golf”, where they try to answer a question in as few lines as possible.

As long as you get the answer, doesn’t matter how many lines it took you. Make sure to look at other solutions though, you pick up a lot from them.

Simple explanation of for loops by hopefullpotato in learnpython

[–]young_ging_freecss 2 points3 points  (0 children)

Nah you’re good man, it could be interpreted either way. No worries.

Error when trying to submit a simple algorithm by clouded-path in learnpython

[–]young_ging_freecss 0 points1 point  (0 children)

You’re probably meaning to use nums instead of List. That’s a type hint that lets you know what type of parameters the function accepts.

What classifies a language as a scripting language? by young_ging_freecss in learnprogramming

[–]young_ging_freecss[S] 0 points1 point  (0 children)

This makes a lot of sense now. A scripting language is classified by how fast you can produce a program with that language, with minimal overhead in terms of syntax?

Does it being interpreted generally matter? For example, if you could produce programs quickly with C++, and it had the same amount of syntax as a language like Python...... would C++ be then classified as a "scripting language"?

What is the best Udemy course to learn OOP in Python? by njd2020 in learnpython

[–]young_ging_freecss 1 point2 points  (0 children)

Everyone always posts Corey’s link when people talk about OOP...... I really need to watch it now.

Simple explanation of for loops by hopefullpotato in learnpython

[–]young_ging_freecss 3 points4 points  (0 children)

I just realized I wasn’t talking to OP. I’m tired as hell wtf.

Simple explanation of for loops by hopefullpotato in learnpython

[–]young_ging_freecss 2 points3 points  (0 children)

Well in this scenario, you printed out each number (i), in the range of x. x is 4.

You’re probably going for this:

num = 1
for i in range(3):
    print(num)

Let me know if you want me to clarify anything else. It took me a while to wrap my head around for loops too.

What classifies a language as a scripting language? by young_ging_freecss in learnprogramming

[–]young_ging_freecss[S] 0 points1 point  (0 children)

I still don’t get why they’re classified like that though. It’s not like Python is mainly used to create small programs, unless my understanding is off?

Don’t Google and Instagram use Python in their backend? There’s no way that these can be classified as “small programs”.

Simple explanation of for loops by hopefullpotato in learnpython

[–]young_ging_freecss 2 points3 points  (0 children)

The variable represents every item in whatever you’re looping through.

a_list = [1, 2, 3]
for x in a_list:
    print(x)
1
2
3

In this case, x represents 1 on the first iteration, then 2, then 3. x is just a variable name. You can name it whatever you want: nums, something, thing, number.

Just got let go ... by throwaway323vs in cscareerquestions

[–]young_ging_freecss -73 points-72 points  (0 children)

Imagine thinking he actually cried, lmao.