Very basic Hangman game in Python I'm trying to learn Python, so I made this project. I think there are problems with the code, but I don't know how to improve it.

import os
import random
clear = lambda: os.system('cls')
def game():
    def printOutCorrectGuess():
        print('Correct! There is/are ', lettersInWord, 'of this letter in this word.')
    def printOutStars():
        print('Currently revealed of the word: ', ''.join(stars))
    def printOutVictory():
        print('You won!')
        print('The word was ', theWord)
        print('Press enter to quit...')
    def printOutWords():
        print('You guessed these letters : ', words)
    def printOutLifes():
        print('You have ', lives, ' more lives.')
    print("Let's start guessing!")
    correctLetters = 0
    lives = 10
    words = []
    stars = list('*' * len(theWord))
    while True:
        guess = str(input('Please give me a letter: '))
        if len(guess) &gt; 1 or len(guess) &lt; 1:
            clear()
            print('I need 1 and letter, thanks.')
            printOutStars()
        elif guess in words:
            clear()
            print('You already wrote this letter.')
            printOutStars()
        elif guess in theWord:
            theStart = 0
            theEnd = 1
            lettersInWord = 0
            letterPosition = []
            for i in range(len(theWord)):
                tempWords = theWord.find(guess, theStart, theEnd)
                theStart = theStart + 1
                theEnd = theEnd + 1
                if tempWords &gt;= 0:
                    lettersInWord = lettersInWord + 1
                    letterPosition.append(i + 1)
                    stars[i] = guess
            correctLetters = correctLetters + lettersInWord
            if correctLetters == len(theWord):
                clear()
                printOutVictory()
                if input() == '':
                    break
                else:
                    break
            clear()
            printOutCorrectGuess()
            printOutStars()
        else:
            lives = lives - 1
            if lives == 0:
                clear()
                print('You lost.')
                print('The word was: ', theWord)
                print('Press enter to quit the game')
                if input() == '':
                    break
                else:
                    break
            clear()
            printOutLifes()
            printOutStars()
        if guess not in words and len(guess) == 1:
            words.append(guess)
        printOutWords()
def welcome():
    print('Now we will play the classic Hangman game, but for this time without drawing it.')
    print('1 or 2 player game mode? Write 1 or 2 please.')
welcome()
while True:
    try:
        gameMode = int(input('INPUT: '))
    except ValueError:
        print('Write 1 or 2 please.')
        continue
    if gameMode == 1:
        words = ['letters', 'sloppy', 'bedroom', 'jazzy', 'discovery', 'wistful', 'unadvised', 'help', 'line', 'shake', 'mend', 'time', 'attempt', 'dare', 'straw', 'destroy', 'health', 'shiny']
        theWord = random.choice(words)
        clear()
        game()
        break
    elif gameMode == 2:
        theWord = str(input('Please write here the word: '))
        clear()
        game()
        break
    elif gameMode &lt; 1 or gameMode &gt; 2:
        print('Write 1 or 2 please.')
Brand new to programming myself, but here's what I've got for you.

This is just different formatting to not call print so many times:

def printOutVictory():
    print('You won!')
    print('The word was ', theWord)
    print('Press enter to quit...')


Alternate format:

# snake_case over camelCase in python
def print_out_victory(): 
    message = "You won!\nThe word was " + theWord
    message += "\nPress enter to quit..."
    print(message)


You could clean up your main body by creating game_mode_1 and game_mode_2 outside of main and calling them for your if and elif and then just reduce your last elif to an else statement:

def game_mode_1():
    words = ['letters', 'sloppy', 'bedroom', 'jazzy', 'discovery', 'wistful', 'unadvised', 'help', 'line', 'shake', 'mend', 'time', 'attempt', 'dare', 'straw', 'destroy', 'health', 'shiny']
    theWord = random.choice(words)
    clear()
    game()
    break

def game_mode_2():
    theWord = str(input('Please write here the word: '))
    clear()
    game()
    break


You would then have: 

#using game_mode in place of gameMode, snake_cases again
def main():
    welcome()
    while true:
        try:
            game_mode = int(input('INPUT: '))
        except ValueError:
            print('Write 1 or 2 please.')
            continue

        if game_mode == 1:
            game_mode_1()

        elif game_mode == 2:
            game_mode_2()

        else:
            print("Write 1 or 2 please.")


Furthermore you could reduce main by creating user_selection

def user_selection():
    while true:
        try:
            game_mode = int(input('INPUT: '))
        except ValueError:
            print('Write 1 or 2 please.')
            continue

        if game_mode == 1:
            game_mode_1()

        elif game_mode == 2:
            game_mode_2()

        else:
            print("Write 1 or 2 please.")


And then your main would look like this

def main():
    welcome()
    user_selection()


Then run main adding if __name__ == '__main__': guard, this will prevent main from running if you import this script into another script

if __name__ == '__main__':
    main()