0

Initials

You need to take the first and last name of a person as input and output the initials (first letters of the first and last name). Sample Input James Smith Sample Output J.S. Can not get the . In my code please help fname = input() lname = input() str = fname str1 = lname x= ([0]) y= (str1[0]) print(x,y,)

15th Jan 2022, 3:42 PM
Mark Crawford
Mark Crawford - avatar
4 ответов
+ 3
x = str[0] Also, you can concatenate two/more strings using `+` operator.
15th Jan 2022, 3:52 PM
Simba
Simba - avatar
+ 2
You need to use single or double quotes to denote a string. 'Mark' or "Crawford"
15th Jan 2022, 4:26 PM
Simba
Simba - avatar
+ 1
It's very simple: fname = input() lname = input() print(fname[0]+"."+lname[0]+".")
13th May 2022, 6:04 AM
Leon Butk
Leon Butk - avatar
0
Ok that worked so now i have JS how do I get it to look like J.S. I tried print(x+”.”+y+”.”) did not work
15th Jan 2022, 4:20 PM
Mark Crawford
Mark Crawford - avatar