I am a beginner programmer and I would like to improve in coding and develop my skills. That is why I am asking this question, what should I focus on improving in this code ?
import random
import re
# this is the file that contains all the words
from words import words
# the word that the user needs to guess
the_guess_word = random.choice(words)
n = 0
t = 0
# puts the random picked word in a list
l_guess = list(the_guess_word)
box = l_guess
# somethings are not yet finished
print("Welcome To The Guessing Game . \n You get 6 Guesses . The Words Are In Dutch But There Is 1 English Word . "
f"\n \n Your Word Has {len(the_guess_word)} letters ")
class hangman():
t = len(box)
right_user_input = []
# should create the amount of letters in the word
right_user_input = ["." for i in range(len(the_guess_word))]
k = len(right_user_input)
while True:
# the user guesses the letter
user_guess = input("guess the word : ")
# if user guesses it wrong 6 times he or she loses
if n >= 6 :
print("you lose!")
print(f'\n the word was {the_guess_word}')
break
# loops over until user gets it right or loses
if user_guess not in the_guess_word:
print("\n wrong guess try again ")
n += 1
if len(user_guess) > 1 :
print("chose 1 letter not mulitple words ")
# when user gets it right the list with the dots gets replaced by the guessed word of the user
if user_guess in the_guess_word :
print("you got it right")
# finds the position of the guessed word in the to be guessed the word
for m in re.finditer(user_guess, the_guess_word):
right_user_input[m.end()-1] = user_guess
print(right_user_input)
# checks to see if user guessed all the words right
if '.' not in right_user_input:
# user now needs to put in the full word to finish the game.
final = input("what is the final word? : ")
if final == the_guess_word:
print('YOU GOT IT ALL RIGHT GOOD JOB !!!')
break
# loses if he gets it wrong end ends the game
else:
print("you got it wrong , you lose ! ")
break