<jupyter_start><jupyter_text>Generate a number from 1 to 10 (bonus point if the number is random)ask the user to guess a number from 1 to 10if the number is wrong, ask againif the input is not a number, ask again for an inputif the input is correct, show "YOU WIN AFTER x ATTEMPTS", where x is the number of guesses<jupyter_code>import random as rd

solution = rd.randint(1, 10)
solution
def ask_integer():
    answer = input("I am thinking of a number from 1 to 10")
    try:
        answer = int(answer)
    except ValueError:
        print("I said a number")
    return answer<jupyter_output><empty_output><jupyter_text>Test Function<jupyter_code>a = ask_integer()
a
b = ask_integer()
b<jupyter_output><empty_output><jupyter_text>Exercise<jupyter_code>count = 0

answer = ask_integer()
    
while answer != solution:
    print("Try again")
    answer = ask_integer()
    count += 1
    
print("YOU WIN AFTER", count, "ATTEMPTS")<jupyter_output>I am thinking of a number from 1 to 106
YOU WIN AFTER 1 ATTEMPTS<jupyter_text>Exercise withou counting wrong answers (when user inserts a str)<jupyter_code>answer = ask_integer()

if type(answer) is int:
    count = 1
else:
    count = 0
    
while answer != solution:
    print("Try again")
    answer = ask_integer()
    if type(answer) is int:
        count += 1
    
print("YOU WIN AFTER", count, "ATTEMPTS")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09071274298056156, 'fraction_numerical': 0.01583873290136789, 'mean_word_length': 4.054545454545455, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '614804', 'license': 'MIT', 'n_tokens_mistral': 488, 'n_tokens_neox': 449, 'n_words': 163, 'path': 'What we did in class/ExercisesSolution/SolutionExercise3.ipynb', 'repo_name': 'ElLorans/PythonCrashCourse', 'size': '1389'}