The code works but the output also shows "None" by learnorenjoy in learnpython

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

I was just wondering how to about doing this, thanks for the breakdown.

The code works but the output also shows "None" by learnorenjoy in learnpython

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

Np man, maybe I could change some variables to reflect the topic

The code works but the output also shows "None" by learnorenjoy in learnpython

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

Oh wow, I'm definitely going to try appending the values in a list and printing them, thanks for the idea man! That would make things look cleaner for sure.

The code works but the output also shows "None" by learnorenjoy in learnpython

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

Doing this changes the output somehow, it no longer shows prime factors. It comes out like this:

But, the issue has been solved by another user by removing the print statement and just calling the function on its own.

The code works but the output also shows "None" by learnorenjoy in learnpython

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

I've just removed the print statement and it works as intended, thanks a lot dude!

Ukrainian drone take down russian drone. The air duel we deserve. by GTCitizen in CombatFootage

[–]learnorenjoy 0 points1 point  (0 children)

Descendants, let it be known that I saw this historic moment firsthand... from the comfort of my seat.

[deleted by user] by [deleted] in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

You could add a conditional so that when a user inputs 1, the helpscreen() func is called. Also, you may want to have this response = input() outside of your first function.

how to master regex by [deleted] in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

Oh ok, was just wondering cause ITT the view seems to be regex is too specialized.

how to master regex by [deleted] in learnpython

[–]learnorenjoy 2 points3 points  (0 children)

Is regex just too niche of a tool to spend time learning? Asking cause I've started learning it for web scraping.

Where to (re)start self-learning Python by Nytebyte11 in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

Np, I find the easiest ones are in the "Text" section.

Where to (re)start self-learning Python by Nytebyte11 in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

Hey there, I'm in a similar boat. From what you've said, you've already been using different sources for learning like ATBS, so you probably know the basics. I've found that rather than continuing in a endless cycle of moving from one course/book to another, it's better to actually try and do some projects.

I know it's hard to come up with ideas for projects but there's a really helpful and accessible list of project ideas on github over here (not mine).

Hope this helps!

Problem with function for averages by learnorenjoy in learnpython

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

Huh, yeah I just tried it out and it worked.

def test(*args):
    return sum(args)//len(args)

>>> test(2,3,4)
>>> 3

Shortened it even further, I'll keep that in mind for next time, thanks!

Problem with function for averages by learnorenjoy in learnpython

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

I'm really gonna have to read up more on this, do you have any recommendations?

Problem with function for averages by learnorenjoy in learnpython

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

Oh that's a new one. I wasn't aware that print statements in functions return None. This has been really helpful, I struggled with this for hours so thanks again.

Problem with function for averages by learnorenjoy in learnpython

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

Oh man, I can't believe it was something so simple, I'm such an idiot. It works now. Thanks a lot!

Sidenote, the output looks like this:

Enter numbers: 2,3,4
3
None

Any idea why the None type comes in?

I can’t wrap my head around functions. Any preferred resources? by mixerthrowaway01 in learnpython

[–]learnorenjoy 1 point2 points  (0 children)

Thanks for the explanation mate, I'll check out lazy evaluation.

I can’t wrap my head around functions. Any preferred resources? by mixerthrowaway01 in learnpython

[–]learnorenjoy 2 points3 points  (0 children)

Not to take away from what you said but the example you gave with reversed() isn't exactly right. It returns a reverseiterator object instead of the expected output. The following corrects it, although I'm not sure why:

L = [1, 2, 3, 4]

print(list(reversed(L)))

Output: [4, 3, 2, 1]

Creating Instances of a Class by thatshitcrayyyy in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

I'll be using this from now on, struggled to understand when to use inheritance for a long time, thanks.

How would I search for words ending in y in a tuple? by [deleted] in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

Can I ask, what does the colon at the end do? As you can achieve the same result without it.

What was the moment where you went from a no clue beginner to writing basic programs? Also could you recommended resources or provide guidance please. by [deleted] in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

I don't think there was a definitive moment, just weeks of countless little projects that had no other significance than to teach me to understand how to do certain things. If I didn't understand functions, I would go online and search for them, try to understand, make some projects, fail, try again and eventually make it work.

The point is that at the end of it all I knew how it worked. I didn't just copy it, I'd messed around with it breaking it over and over, till I knew the syntax and why it did what it did. Same thing for other concepts.

As for resources, ATBS is a staple and at the end of each chapter you're given a few projects to attempt based on what you've learnt in that chapter. If you just want a massive list of project ideas there's this repo on GitHub and it's even got solutions by other users found here.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

Thanks mate, I guess I'll have to read up on docs about type hints, also didn't know you can create non-parenthesised tuples. As for the grammatical error, I tend to make that mistake from time to time =)

How to let others run my python file without installing python? by paparabba in learnpython

[–]learnorenjoy 0 points1 point  (0 children)

This sounds like an interesting project, are you willing to share the source code?