Image source
Repository: Python, Open Source Repository
What you will learn?
- Coding a guessing game (no graphics)
REQUIREMENTS: - SMARTPHONE
- QPYTHON 3
DIFFICULTY: BASIC
TUTORIAL CONTENTS
This code was written when I started coding, then I didn't know about class so that's why I didn't add one and besides this code doesn't need a class cause it's a simple one.
import sys
import os
import subprocess as sp
from getpass import getpass
from time import sleep
entered = []
clap = []
realword = getpass("Enter a word you would like someone to guess from")
hint = input("Write a hint.\nNote: This is not the word and can be seen by the people guessing the word. >>>")
print("Please wait while we load the game...")
fling = realword.upper()
realword = realword.upper()
sleep(5)
sp.call('cls' ,shell = True)
b = len(realword)
l = len(clap)
l = l + 1
y = len(realword)
y = y + 3
t = 1
while t <= y:
print(str(t) + " of " + str(y) + " tries.")
print("Hint: " + hint + "...")
enter = input("Can you guess a letter in the word >>>")
enter = enter.upper()
if enter in realword:
entered.append(enter)
else:
print("Wrong answer!")
for g in realword:
if g in entered:
print(g + "\t")
clap.append(g)
else:
print("------")
l = len(clap)
while b == l:
print("Congratulations!!!\nYou have figured it all out!!!")
sleep(10)
sys.exit()
del clap [:]
t += 1
sp.call('cls' ,shell = True)
print("Sorry you could not figure it out within the number of tries...\nThe word was " + fling)
print(" ")
print(" o o o o o ")
print(" o o ")
print(" o o")
print(" o o o o")
print(" o o")
print(" o o")
print(" o v o")
print(" o o")
print(" o o")
print(" o ______ o")
print(" o ( ) o")
print(" o o")
print(" o o o o o ")
sleep(10)
It's a simple code and no graphics so I added the dots to give it little graphics. This game consists of two players where one inputs the word that he wants the other to guess, I coded the actual word to disappear immediately it's inputted. The clues are given based one how many letters the word to be guessed is. The output should look like this
When you win there's a kind of smiley face that congratulates you.
Proof of work
GITHUB REPOSITORY
Thank you for your contribution.
This moderation might not be considered due to the below:
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Please can I edit it and try again
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You have collected your daily Power Up! This post received an upvote worth of 0.29$.
Learn how to Power Up Smart here!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit