#๐ Hangman
30 messages ยท Page 1 of 1 (latest)
@ebon crystal
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.
I have a hangman assignemnt for homework and im unsure how to make the letters display themseleves when they are guessed....
here is my code..
its not printing "Hi"
!e ```py
current_phrase = "this is the current phrase."
print(current_phrase)
current_phrase[0].capitalize()
print(current_phrase)
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | this is the current phrase.
002 | this is the current phrase.
Python strings are immutable so if you want to change it you'll have to assign the new string to the variable name
also that just capitalizes the substring located at current_phrase[0]. Do you want to capitalize the entire word?
oh i guess so, cuz i capitalized "letter", im going to change it to upper
still doesnt print hi... letter should be in currentPhrase???
letter = letter.upper()
if letter in currentPhrase:
print("Hi")``` still doesnt work this way....
What does "doesn't work" mean? print out both of those things and make sure they are the same letter
also currentPhrase[0].capitalize() just capitalizes and returns that letter
i switched out the capitalize with upper():
you're still operating on the substring located at that index
!e ```py
s = "this is a string"
s = s[0].upper()
print(s)
:white_check_mark: Your 3.12 eval job has completed with return code 0.
T
I have to step away now.
but its a list not a variable? the index 0 is the whole phrase??
ok, thanks anyways
ty
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.