r/learnpython • • Oct 26 '26

how do i overwrite a variable?

name = "Alice"

def func():
    name = "Bob"

func()

print(f"Hello, {name}!") # i want it to print bob
0 Upvotes

35 comments sorted by

View all comments

Show parent comment

2

u/Langdon_St_Ives Oct 26 '26

What a feeble argument. There is a lot of stuff in there that is useful to have in principle but has very limited and well-defined uses. If you fail to see the subtlety between saying you "practically never" want to use it and saying it shouldn't be in the language, I have nothing more to say to you. The point stands, it's terrible advice to a beginner as a solution to their x-y problem.