#๐Ÿ”’ Beginner Help with Python how to insert a character in a variable from a string

24 messages ยท Page 1 of 1 (latest)

kindred bearBOT
#

@glossy sinew

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

glossy sinew
#

word_list = ["ardvark", "baboon", "camel"]
random_word = random.choice(word_list)
ask_letter = input("What is your letter?").lower()
correct_letter =

heavy forum
#

what are you trying to do?

glossy sinew
#

sorry for my poor English. I'm trying to insert one of the letters in the word list into the correct_letter variable

#

for example, if the random_word is baboon, the correct_letter variable should get the letters from the baboon

#

its for a hangman project im doing

heavy forum
glossy sinew
#

yes

#

but it's a random word chosen off the list
so i cant just write the individual letters

heavy forum
#

ooooh i think i get it so basically

#

your turning the random word into a list

#

and if the users input is in that list they get it correct or something

#

?

glossy sinew
#

yes

#

its kind of like hangman

heavy forum
#

just use list()

glossy sinew
#

got it

#

thanks

untold chasm
#

You can use a set to strip duplicate letters for you, if you don't care about their position.
But in your case it's probably not necessary

#

!e

word = "your word"
unique_chars = set(word)

print(unique_chars)```
kindred bearBOT
glossy sinew
#

ok

kindred bearBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.