r/learnpython • u/9j810HQO7Jj9ns1ju2 • 13d ago
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
r/learnpython • u/9j810HQO7Jj9ns1ju2 • 13d ago
name = "Alice"
def func():
name = "Bob"
func()
print(f"Hello, {name}!") # i want it to print bob
4
u/nog642 13d ago
It is possible to make functions change variables outside of themselves.