Untitled
unknown
python
a year ago
311 B
5
Indexable
x = 10 # Global variable
def add_to_x(y):
global x # Declare x as global
x += y # Modify the global variable
add_to_x(5)
print(x) # Outputs: 15
def write_to_file(filename, data):
with open(filename, 'w') as f:
f.write(data)
write_to_file('test.txt', 'Hello, World!')
Editor is loading...
Leave a Comment