sadennison

Python Week 4 Task 4.2

Aug 6th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #Change the program so that it keeps a count of the number of times it took you to guess the name, and then outputs the total when you guess correctly
  2. guess = input("guess my name ")
  3. count = 1
  4. while guess != "Martin":
  5. guess = input("wrong - guess again ")
  6. count = count + 1
  7. print("well done")
  8. print("You took " + str(count) + " attempts")
Advertisement
Add Comment
Please, Sign In to add comment