Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
3

The Guessing Game!

Renise
Renise

This is the guessing game, you must guess the computer's number. There are 2 rounds and well the description is told to you in the game.. Give some suggestions and feedback on the game, I am a beginner so yeah!

2 years ago

Voters

Comments

TopNew
2
elipie
elipie

hello! cool program! instead of just picking a random number for the code this can be done! :

import random import os num = random.randint(1,100)#can be more than just a hundred # something to spice it up: guesses = 15#edit this to your liking print(num) for i in range(guesses): num_guess = int(input("What is your guess?\n>")) try: if num_guess > num: os.system('clear') print("Too high!\nYou have "+str(guesses)+" more guesses!") guesses = guesses - 1 elif num_guess < num: os.system('clear') print("Too low!\nYou have "+str(guesses)+" More guesses") guesses = guesses - 1 else: os.system('clear') print("You got it!\nWith "+str(guesses)+" guesses left!") break guesses = guesses - 1 except: os.system('clear') print("Enter a number!!") break if guesses == 0: print("Oh no! You ran out of guesses!! The number was: "+str(num))

str() basically tells python it is a string, because if you just put

variable = 1234 print("Hello, "+variable)

That will generate an error, because python thinks you are trying to add the string Hello, with the number 1234 which is impossible.

Thanks for reading!!

Also line 34 there is an extra )

2 years ago
1
Renise
Renise

@elipie
Omg thank you so much! I will try it out :D

2 years ago
1
Renise
Renise

@elipie
Ok I finished, try it out! If you like it upvote :D (Btw i credit you at the end again thank you)

2 years ago
2
elipie
elipie

@Renise
yey, it so fun!

2 years ago
2
Gr8est
Gr8est

You have an error

2 years ago
1
1
Gr8est
Gr8est

@Renise
, when I run it, it is saying:
File "main.py", line 34
print("Have a great day!") )
SyntaxError: unmatched ')'

2 years ago
1
Renise
Renise

@CrashBatBat
Okay, I will fix it now, thank you for the feedback!

2 years ago
1
Renise
Renise

@CrashBatBat
Ok I fixed it, try it now :)

2 years ago
2
Gr8est
Gr8est

Nice, it's pretty good. ;-)

2 years ago
1
Renise
Renise

@CrashBatBat
Yayyy this is my first functional code :D thanks for the support

2 years ago
2
Gr8est
Gr8est

@Renise
, you deserve it!

2 years ago
1

I cant talk to you anymore, cya in 2 months

2 years ago
Load more