Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

In a modify task you take code that already works and adapt it so that it does something else.

The editor starts you off with this number-guessing program:

number = 5
print("I have thought of a number between 1 and 10")
print("Can you guess what it is?")
guess = int(input())

if guess < number:
    print("Too Low!")
if guess > number:
    print("Too High!")

It tells the user when a guess is too small and when it is too big, but it says nothing at all when the guess is right, and it never asks the user how they think they did.

Your task

Adapt the code so that it does three more things. Leave everything that is already there exactly as it is.

Ask the new question with its own print, exactly as written:

Did you guess correctly?

The questions and the messages are all part of the checked output, and are checked exactly as they are written here, capital letters and exclamation marks included:

Can you guess what it is?
Too Low!
Too High!
Bad luck!
Did you guess correctly?
Well done!
Never mind!

The answer to the second question is compared with yes in small letters. Comparing text is case sensitive, so an answer of Yes or YES does not match and gets the Never mind! message. That is the correct behaviour here, and it is tested.

Example

A guess that is too small, from a user who admits it:

Input:

2
no

Output:

I have thought of a number between 1 and 10
Can you guess what it is?
Too Low!
Bad luck!
Did you guess correctly?
Never mind!

A correct guess:

Input:

5
yes

Output:

I have thought of a number between 1 and 10
Can you guess what it is?
Did you guess correctly?
Well done!

The second output is shorter because a correct guess is neither too low nor too high nor unequal to the number, so all three of those branches are skipped.

Help! My code doesn't work!

Make sure that you check for the following things:

  • There is a colon (:) at the end of every if line and every else line.
  • Every line inside a branch is indented, and all of them by the same amount. Never mix tabs and spaces in one file.
  • There is no condition after else.
  • You have used a double equals (==) in a condition that checks whether two pieces of data are the same, and != to check that they are different. A single = stores data in a variable.
  • You have remembered the brackets after input, and the second closing bracket that int(input()) needs.
  • The answer to the last question is text, so it is not wrapped in int().