Part 8 | Python Programming | Creating a while loop Guessing Game

Publié le: 02 janvier 2023
sur la chaîne: oOSylarTechOo
305
13

This is part 8 of a series of python coding that I am having fun with and want to show others that are interested or stuck.

Code Example:

#Creating a while loop guessing game
#This will loop until a condition has been met

#Declare your starting variables with assigned values
guess = 0
ans = 7

guess = int(input("What is your guess? "))

#Creating the while loop that will continue until the correct
#answer is guessed.
while guess != ans:
guess = int(input("Guess again! "))
if guess == ans:
break
else:
guess = int(input("Guess again! "))

#Convert guess into a string
sGuess = str(guess)

#Print the results of the guess
print("You got it! The answer is " + sGuess)


#python #pythonprogramming #pythontutorial #pythonforbeginners #shorts

Music: Paid Subscription with Wondershare Filmora


Sur cette page du site, vous pouvez voir la vidéo en ligne Part 8 | Python Programming | Creating a while loop Guessing Game durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur oOSylarTechOo 02 janvier 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 305 fois et il a aimé 13 téléspectateurs. Bon visionnage!