fizz_buzz_from_file.py 630 B

123456789101112131415161718192021222324252627282930
  1. from typing import List
  2. #f = open('numbers.txt', 'r')
  3. #line = f.readline()
  4. #while line:
  5. # print(line)
  6. #line = f.readline()
  7. #a = line.split(' ')
  8. #f.close()
  9. with open('numbers.txt', 'r') as f:
  10. line = f.readline()
  11. # for line in f:
  12. # print(line, end='')
  13. a = line.split(' ')
  14. num1 = int(a[0])
  15. num2 = int(a[1])
  16. num3 = int(a[2])
  17. print(a)
  18. print(num1)
  19. print(num2)
  20. print(num3)
  21. for i in range(1, num3 + 1):
  22. if i % num1 == 0 and i % num2 == 0:
  23. print("FB", end = " ")
  24. elif i % num1 == 0:
  25. print("F", end = " ")
  26. elif i % num2 == 0:
  27. print("B", end = " ")
  28. else:
  29. print(i, end = " ")