r/learnpython • u/9j810HQO7Jj9ns1ju2 • 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
View all comments
Show parent comment
2
u/nog642 Oct 26 '26
Arguably it shouldn't be used at all. Some language features need to exist but should only be used when you know you're doing something dirty.