+ 1

Getting errors

Write a Python script, that takes name, surname and title of a person and displays the inputs in a different format: Enter name: Ihsan Enter surname: Dogramaci Enter title: Professor Person is: Prof. Dogramaci, I. Enter name: Hilmi Enter surname: Oncul Enter title: Instructor Person is: Inst. Oncul, H. My attempt was: Name= input ("Enter name: ") Surname= input("Enter surname: ") Title= input ("Enter title: ") print ("Person is:{0:.4s}. {1:s} {2:.1s}.".format(Title,Surname,Name) (But I kept on getting an error that says unexpected EOF while parsing)

29th Sep 2020, 12:18 PM
Sara Maskoun
Sara Maskoun - avatar
3 Antworten
+ 4
Hi Sara Maskoun, As Jayakrishna🇮🇳 said, you are getting SyntaxError due to missing ')'. The following code achieves the same result without the use of .format(). I've used basic print() function and slicing methods... https://code.sololearn.com/c4dQMN42xmL7/?ref=app
29th Sep 2020, 1:52 PM
Rahul Hemdev
Rahul Hemdev - avatar
+ 3
Using f-string makes it easy to get a proper output. it has a better readability than using .format() Name= input ("Enter name: ") Surname= input("Enter surname: ") Title= input ("Enter title: ") print(f'Person is: {Title[0:4]}. {Surname} {Name[0]}.')
29th Sep 2020, 2:55 PM
Lothar
Lothar - avatar
+ 2
You are missing closing brace for last print function. Sara Maskoun add ) last. And SoloLearn takes all the inputs at once only and also before start of execution... So you need to give all the required input only ones beginning.. Edit: For additional info, if you don't know, See this, for how SoloLearn handle input : https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
29th Sep 2020, 12:33 PM
Jayakrishna 🇮🇳