fork download
  1. import random
  2.  
  3. f = open('in.txt')
  4. line = []
  5. while True:
  6. sw = f.readline() # читаем из файла in.txt строки
  7. if len(sw) == 0:
  8. break
  9. line.append(sw)
  10. line[-1] += '\n'
  11. f.close()
  12. random.seed(version=2)
  13. random.shuffle(line) # миксуем список
  14. f = open('out.txt', 'w')
  15. for i in range(5):
  16. f.write(line[i]) # выводим в файл out.txt
  17. f.close()
Runtime error #stdin #stdout #stderr 0.03s 12312KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 3, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'in.txt'