Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List capital letters
#8
text = ...
{i:c for (i, c) in enumerate(text) if c.isupper()}
Dict-Comprehension. The only change is the colon. In this case the keys are the indices and the values are the chars.
By the way, ... is the Ellipsis object. It's used for numpy.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
List capital letters - by ricardodepaula - Jul-21-2019, 05:09 PM
RE: List capital letters - by Yoriz - Jul-21-2019, 05:27 PM
RE: List capital letters - by DeaD_EyE - Jul-21-2019, 05:42 PM
RE: List capital letters - by ndc85430 - Jul-21-2019, 05:43 PM
RE: List capital letters - by DeaD_EyE - Jul-21-2019, 06:53 PM
RE: List capital letters - by ricardodepaula - Jul-21-2019, 11:35 PM
RE: List capital letters - by ndc85430 - Jul-22-2019, 05:37 AM
RE: List capital letters - by DeaD_EyE - Jul-22-2019, 06:45 AM
RE: List capital letters - by ricardodepaula - Jul-23-2019, 03:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  item from a line to list however when i print the line instead of words i get letters Sutsro 5 3,048 Apr-22-2020, 02:39 PM
Last Post: deanhystad
  Pynput - no capital letters jmair 2 4,622 Feb-12-2019, 09:53 PM
Last Post: jmair
  make a list of string in capital by using a function anancba 3 3,497 Nov-23-2017, 06:42 AM
Last Post: heiner55
  Ending loop with string (capital & lowercase) MattWilk97 3 3,495 Oct-22-2017, 09:13 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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