Ask coding questions

← Back to all posts
Plzzz help!
CodingKid2874 (35)

I'm a baby when it comes to coding. (3 weeks old to be exact) but I got the hang of the text based story things anyway that's unrelated...I have a few problems in this code that I don't know how to fix!

PROBLEM 1.) I don't know how to make the code pick a random word, I have a word at the top that I have to change each time I ask someone to play and I want it to be a random selection of for example a word list but IDK how :(.

PROBLEM 2.) In my code it says, MAX ATTEMPTS and it tells you how many attempts you have. I want it to be like if you pass the max attempts then you lose.

PROBLEM 3.) At the very bottom it says if all the characters that the user guessed is in the word then print YOU WON! but for some reason it's not actually printing that.

Please help me if you can but if you don't want to I get it. HAVE A NICE DAY!!! づ(。 ◕‿‿◕。) づ づ(。 ◕‿‿◕。) づ づ(。 ◕‿‿◕。) づ づ(。 ◕‿‿◕。) づ づ(。 ◕‿‿◕。) づ づ(。 ◕‿‿◕。) づ

Codejira (165)

You created the word list almost correct. It's words = list("pineapple", "banana", "Abrams M1A1").

To chose a random item from a list you import random at the beginning of your program and then call word = random.choice(words).

At some point you have to define the max number of attempts. When playing you count the attempts in another variable and compare the two

if attempt > maxattempt:
    print("You lose!")
    attempt += 1
    print("Try again")

Line 48: all can take a list comprehension as argument but I guess there are other ways. Anyway you have to compare all the player's guesses to the secret word.

CodeLongAndPros (1359)


from random import choice
words = ['repl', 'Linux', 'Ubuntu', 'arch', 'btw']

Replace words with an list of words