One of the bugs was, if the random number was even, it didn't get added to the file - but the for i in range(15): continues to the next iteration - so you don't end up with 15 numbers.
import random
numbers = []
# With/open is the preferred technique to write.
# Use a separate with open to read at the end.
# Dont try to keep reading and writing from the same file, while it stays open
with open('text','w+') as f:
for i in range(15): # This will loop 15 times
x = random.randint(0,25) # Set the random int first, so the while loop can evaluate
while x%2 == 0: # if X is even, This will keep looping until it is odd
x = random.randint(0,25)
numbers.append(str(x)) # Dont know what this is for
f.write(str(x) + ' ')
print("----------------")
with open('text','r') as f:
print(f.read())
open('text', 'rw+')mode. When you finish with writing odd numbers, you should jump to the start of the file usingf..seek(0, 0)and then read form it.