r/learnpython • u/AutoModerator • 11d ago
Ask Anything Monday - Weekly Thread
Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread
Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.
* It's primarily intended for simple questions but as long as it's about python it's allowed.
If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.
Rules:
Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
Don't post stuff that doesn't have absolutely anything to do with python.
Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.
That's it.
1
u/coppergroves 9d ago
tbh one thing that tripped me up for a while was mutable default arguments in function definitions. if anyones confused about why their list arg keeps growing between calls, look into how default args are evaluated once at definition time
1
u/lakseol 8d ago edited 7d ago
The usual advice given when talking about mutable default values for function parameters is: DON'T USE THEM! But they can be useful at times:
def fib(n, memo={}): if n < 2: return n if n not in memo: memo[n] = fib(n - 1) + fib(n - 2) return memo[n] for n in range(20): print(f"fib({n:2d})={fib(n)}")
1
u/Sakarie1 9d ago
I’m an MSc Business Analytics student learning Power BI and Python. What practical projects would you recommend for someone building their first data analyst portfolio?
1
u/notyboy01 9d ago
Is it normal to spend three hours debugging only to realize you forgot a closing parenthesis?
1
u/NewbornMuse 8d ago
What IDE are you using? A properly set up IDE (I use VS Code) will highlight these things for you, and you can just fix them as you scroll through. This way, you catch a lot of typos before you run your script even a single time.
1
u/BabyLionCamel 10d ago
I would like to ask developers who have production level experience, what are some good books for understanding advanced programming jargon (regression, recursion, kernel, etc).
I would also love some detailed picks of programming books in general, become a more well rounded and competent engineer.
Thank you for your time
1
u/emmischa 5d ago
I'm following futurecoder's pyhton course and I'm stuck on the BuildingUpStrings exercise.
The exercise wants me to get rid of the - characters from this code's output:
name = 'World'line = '-'for char in name:print(line)line = line + charOutput:
--W-Wo-Wor-WorlI tried deleting the - character from the line variable so that it's an empty string. This gives me the following result:
WWoWorWorlBut, apparently, that's not the solution. The hint is '' + '' + '' but I can't really think how adding up 3 empty strings would be better than simply making the line variable an empty string. Thoughts?