Advertisement
veronikaaa86

04. Walking

Jul 31st, 2022 (edited)
1,168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # "1000"  "1500"  "Going home"
  2.  
  3. sum_steps = 0
  4. is_reached = False
  5. input_line = input()
  6. while input_line != "Going home":
  7.     steps = int(input_line)
  8.     sum_steps += steps
  9.  
  10.     if sum_steps >= 10000:
  11.         is_reached = True
  12.         break
  13.  
  14.     input_line = input()
  15.  
  16. if input_line == "Going home":
  17.     steps_home = int(input())
  18.     sum_steps += steps_home
  19.     if sum_steps >= 10000:
  20.         is_reached = True
  21.  
  22. diff = abs(10000 - sum_steps)
  23. if is_reached:
  24.     print("Goal reached! Good job!")
  25.     print(f"{diff} steps over the goal!")
  26. else:
  27.     print(f"{diff} more steps to reach goal.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement