Python Forum
Explaining "translate" method
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Explaining "translate" method
#2
(Jan-11-2020, 07:45 AM)lummers Wrote: Write a program that allows a user to type in a phrase and provides the acronym as the output. The acronym should be in uppercase.

Like this?

Quote:How it supposed to work? --> HISTW

Task in spoken language: 'take first letter and make it uppercase for every word in sentence and join them into new string'

In [1]: s = 'How it supposed to work?'                                    

In [2]: ''.join([word[0].upper() for word in s.split()])                  
Out[2]: 'HISTW'
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
Explaining "translate" method - by lummers - Jan-11-2020, 07:45 AM
RE: Explaining "translate" method - by perfringo - Jan-11-2020, 08:33 AM
RE: Explaining "translate" method - by Gribouillis - Jan-11-2020, 09:08 AM
RE: Explaining "translate" method - by ndc85430 - Jan-12-2020, 05:33 PM
RE: Explaining "translate" method - by perfringo - Jan-13-2020, 06:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  for loop and if translate from R in Python Joey21 3 3,992 Feb-06-2018, 02:16 PM
Last Post: sparkz_alot
  Need help explaining what the variables do in my code. BurnedChipotle 6 6,270 Jan-30-2017, 10:48 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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