princessbrebre2935 princessbrebre2935
  • 12-07-2022
  • Computers and Technology
contestada

2.12 lab: name format many documents use a specific format for a person's name. write a program whose input is: firstname middlename lastname and whose output is: lastname, firstinitial.middleinitial.

Respuesta :

Talanat
Talanat Talanat
  • 19-07-2022

Answer:

if __name__ == '__main__':

   user_input = input()  # read name

   name = user_input.split()  # split name into separate words

   if len(name) == 3:  # if number of words in name is 3

       print(name[2] + ", " + name[0][0] + "." + name[1][0] + ".")

   elif len(name) == 2:  # if number of words in name is 2

       print(name[1] + ", " + name[0][0] + ".")

Explanation:

The code is written in "Python".

Answer Link

Otras preguntas

how long has Columbia been a country
When momentum is transferred from one object to another, the total amount of momentum in the system (is/ is not) conserved
If I score 13 out of 24 in a test , what percentage is this ?
If I score 13 out of 24 in a test , what percentage is this ?
Jana bought a car for $4200 and later sold it for a 30% profit. How much did Jana sell the car for?
Compare the adult frog to the tadpole.
ions containing oxygen are colourless, is this true?
According to one acid-base theory, a base is an(A) [tex]H^+[/tex] acceptor(B) [tex]Na^+[/tex] acceptor(C) [tex]H^+[/tex] donor(D) [tex]Na^+[/tex] donor
???????????? Can I has h
Can you help me with this one ? Factor 2x2 + 7x + 3.A.(2x + 1)(x + 3)B.(2x + 3)(x + 1)C.(2x + 5)(x + 1)D.The polynomial is prime.