I want to make a program that makes a random number and adds it to a file. And I also want to make a "security code" which is the number of the line where the random number is + a random code
My code:
import random
security3 = random.sample(range(10), 4)
security3r = ''.join(map(str, security3))
nummer = random.sample(range(10), 5)
nummerr = ''.join(map(str, nummer))
num_lines = sum(1 for line in open('data.txt'))
print(num_lines)
security6 = int(num_lines) + int(nummerr)
print(security6)
Data.txt:
a
b
c
d
e
f
But every time I run it, it only prints five numbers of security6
- not 6. Why is it not showing 5 numbers instead of 6?
Aucun commentaire:
Enregistrer un commentaire