Name initials python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Name initials python

Here is my code: fname = input() lname = input() #your code goes here print(fname[0],".",lname[0]) My output is J . A The output should be J.A What am I doing wrong?

27th Nov 2021, 2:36 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar
4 Answers
+ 5
print() use softspace " " as separator. You can use your own: print(frame[0], ".", lname[0], sep="")
27th Nov 2021, 2:42 AM
Alexey Kopyshev
Alexey Kopyshev - avatar
+ 3
You can use + instead of the , because the comma inserts a space
27th Nov 2021, 2:46 AM
Mafdi
Mafdi - avatar
+ 1
print(f"{fname[0]},{lname[0]}") or print(fname[0] + "." + lname[0])
27th Nov 2021, 6:44 AM
Alfonso Farías
Alfonso Farías - avatar
0
It is now solved.
27th Nov 2021, 2:48 AM
Kim Hammar-Milliner
Kim Hammar-Milliner - avatar