Python Forum
[split] capitalize dict keys for display in string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] capitalize dict keys for display in string
#4
Something like below?

>>> f"You must pick one from: {', '.join(key.capitalize() for key in categories)}"             
'You must pick one from: I lost my license, Problem saving file'
Or with quotation marks:

>>> f"""You must pick one from: {', '.join(f'"{key.capitalize()}"' for key in categories)}"""                                                                                     
'You must pick one from: "I lost my license", "Problem saving file"'
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: [split] Python Automated Response System Help - by perfringo - Oct-10-2019, 10:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  doing string split with 2 or more split characters Skaperen 22 2,488 Aug-13-2023, 01:57 AM
Last Post: Skaperen
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,122 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  How to display <IPython.core.display.HTML object>? pythopen 3 45,928 May-06-2023, 08:14 AM
Last Post: pramod08728
  [split] Parse Nested JSON String in Python mmm07 4 1,523 Mar-28-2023, 06:07 PM
Last Post: snippsat
  Split string using variable found in a list japo85 2 1,296 Jul-11-2022, 08:52 AM
Last Post: japo85
  Updating nested dict list keys tbaror 2 1,276 Feb-09-2022, 09:37 AM
Last Post: tbaror
  Loop Dict with inconsistent Keys Personne 1 1,607 Feb-05-2022, 03:19 AM
Last Post: Larz60+
  Split string knob 2 1,869 Nov-19-2021, 10:27 AM
Last Post: ghoul
  Create Dict from multiple Lists with duplicate Keys rhat398 10 4,068 Jun-26-2021, 11:12 AM
Last Post: Larz60+
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,231 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray

Forum Jump:

User Panel Messages

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