Advertisement
veronikaaa86

04. Walking

Jul 30th, 2023
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. sum_steps = 0
  2. goal_steps = 10000
  3. input_line = input()
  4. while input_line != "Going home":
  5.     steps = int(input_line)
  6.     sum_steps += steps
  7.  
  8.     if sum_steps >= goal_steps:
  9.         break
  10.  
  11.     input_line = input()
  12.  
  13. if input_line == "Going home":
  14.     steps_home = int(input())
  15.     sum_steps += steps_home
  16.  
  17. diff = abs(goal_steps - sum_steps)
  18. if sum_steps >= goal_steps:
  19.     print("Goal reached! Good job!")
  20.     print(f"{diff} steps over the goal!")
  21. else:
  22.     print(f"{diff} more steps to reach goal.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement