Since yesterday I started to learn python and today I tried to write my first "programm". But I have one problem, I want the programm to save all the generated codes into one .txt file but when its finished it just saves the last code (e.g. 50/50 codes generated but only the last one is saved in the text file).
Thats my code:
Pls help me I cant find a solution in google.
Thats my code:
Code:
import random
chars = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
length = 16
number = input("How many codes?")
number = int(number)
for p in range(number):
code = (" ")
for c in range(length):
code += random.choice(chars)
print(code)
file = open("codes.txt","w")
file.write(code)
file.close()