Python Forum
Creating list out of the first letter of every word in a string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating list out of the first letter of every word in a string
#4
Desired result can be achieved also this way:

>>> mystring = "Secret agents are super good at staying hidden."
>>> [word[0] for word in mystring.split()]
['S', 'a', 'a', 's', 'g', 'a', 's', 'h']
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: Creating list out of the first letter of every word in a string - by perfringo - Oct-05-2018, 05:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Retrieve word from string knob 4 537 Jan-22-2024, 06:40 PM
Last Post: Pedroski55
  extract substring from a string before a word !! evilcode1 3 589 Nov-08-2023, 12:18 AM
Last Post: evilcode1
  For Word, Count in List (Counts.Items()) new_coder_231013 6 2,683 Jul-21-2022, 02:51 PM
Last Post: new_coder_231013
  find some word in text list file and a bit change to them RolanRoll 3 1,575 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  Isolate a word from a long string nicocorico 2 1,571 Feb-25-2022, 01:12 PM
Last Post: nicocorico
  Class-Aggregation and creating a list/dictionary IoannisDem 1 1,954 Oct-03-2021, 05:16 PM
Last Post: Yoriz
  change string in MS word Mr_Blue 8 3,427 Sep-19-2021, 02:13 PM
Last Post: snippsat
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,557 Aug-12-2021, 04:25 PM
Last Post: palladium
  Creating new column with a input string drunkenneo 2 2,289 Apr-14-2021, 08:10 AM
Last Post: drunkenneo
  Trying to get the first letter of every word in a list DanielCook 2 2,186 Jan-05-2021, 05:06 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020