#๐ Extracting only words that begin with a Capital.
28 messages ยท Page 1 of 1 (latest)
@gray ice
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.
!e
``py
@placid hull :warning: Your 3.12 eval job has completed with return code 0.
[No output]
oops
!e
sentence = "You and I visited the Big Ben."
only_caps = list(filter(lambda word: word[0].isupper(), sentence.split()))
print(only_caps)
@placid hull :white_check_mark: Your 3.12 eval job has completed with return code 0.
['You', 'I', 'Big', 'Ben.']
Sorry the list I'm pulling from is a .txt file I named modified
''.join() concatenates the modified list into one single string
it should work if you just remove it and use just modified?
I'll give it a shot
the lambda would have to be changed too, and then you'd end up with what tathya wrote
ah, yes
you need of the [0] on the lambda there to select specifically the first character of each word
you mean you copy pasted Tathya's?..
I did, and then added in modified for my list name.
it'll probably error, but if it does
think for a bit about why, at least this little you should be able to figure out on your own
what are the contents of modified?
they mean it not just conceptually, but rather what is it type in python in practice
(list, string, something else)
it's a list.
you cant split a list using .split()
Thanks for the help guys, I'm going to keep messing around with things till something works.
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.
๐ Extracting only words that begin with a Capital.