lmarkov

04_wolf _in_sheep_s_clothing.py / 06_basic_syntax_conditional_statements_and_loops_more_exercises

Oct 15th, 2021 (edited)
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. animals = input()
  2.  
  3. animals_list = []
  4. for animal in animals.split(","):
  5.     animals_list.append(str(animal).strip())
  6.  
  7. farmer_position = len(animals_list) + 1
  8.  
  9. if animals_list[-1].strip() == "wolf":
  10.     print("Please go away and stop eating my sheep")
  11. else:
  12.     animal_position = len(animals_list) - animals_list.index("wolf") - 1
  13.     print(f"Oi! Sheep number {animal_position}! You are about to be eaten by a wolf!")
  14.  
Add Comment
Please, Sign In to add comment