guessing game | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

guessing game

Hi I had an assignment where i had to do a guessing game to process of guessing a number between 1 and 100. After each guess, the player is told that the guess is too high or too low. The process continues until the player guesses the correct number. it keeps saying no output why? [ "\n", "#------ guess a number ------\n", "\n", "# Player 1 picks a number\n", "while True:\n", " actual_num = float(input(\"Player 1: Pick a number \\n\"))#get Input from player 1 \n", " if actual_num >=1 and actual_num <= 100:\n", " break\n", " print (\"out of bounds. Please retry.\")\n", " \n", "# Player 2 guesses a number\n", "guessed_num = float(input(\"Player 2: Guess the number \\n\"))#get input from player 2(guessed number)\n", "\n", "# loop that runs until player 2 guesses the right number.\n", "while guessed_num != actual_num:\n", " if guessed_num < actual_num:\n", " print(\"too low\")\n", " else:\n", " print(\"too high\")\n", " guessed_num = float(input(\"Player 2: Guess the number \\n\"))\n", "\n", "if guessed_num == actual_num:\n", " print(\"Well Done..!!\")\n", " " ]

13th Sep 2020, 6:32 PM
Jah Revelo
Jah Revelo - avatar
0 Answers