#๐Ÿ”’ I can't figure out why my code doesn't work

7 messages ยท Page 1 of 1 (latest)

grand cargo
#

How can I make this from this:
t!e@s#t t%e^s&t => #TESTTEST

like this:
t!e@s#t t%e^s&t => #TestTest

My code:
import string

user_input = input()
user_input_2 = "".join(i for i in user_input if i not in string.punctuation and i != ' ')
user_input_3 = user_input_2.split()
user_input_4 = "".join(word[0].upper() + word[1:].lower() for word in user_input_3)
user_input_5 = '#' + user_input_4
if len(user_input) > 140:
print(user_input_5[:140])
else:
print(user_input_5)

crimson gobletBOT
#

@grand cargo

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.

noble ingot
#

use the whitespace in the input to separate the words (e.g. store them individually in a list), capitalise each word and then join into the final output

grand cargo
#

Thanks a lot!

unkempt forge
#

theres also title case i think which capitalies all starts of words so u would just remove the special chars do title case and remove spaces

crimson gobletBOT
#
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.