0

Write a python program which accepts a string which contains the First name and last name separated by comma.

Print Full name on the Screen,where First name should be in upper case and Last name in lower case and with a space between them. Input- Ravi, Srivastava Output - RAVI srivastava

10th Dec 2018, 9:10 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
21 Answers
+ 2
Please show your attempt! We're discouraged to write the whole code for others. I hope you understand. Thanks!
10th Dec 2018, 9:18 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
11th Dec 2018, 3:18 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
+ 1
Okay, I can give you hints. Why don't you start by writing a code that accepts the name (separated by comma) from the user, and stores it in a a variable? Please save it in the code playground, and share the link.
10th Dec 2018, 9:31 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
Not like that! You have to accept the name from the user as an input and store it in a variable. Then it'd be the code's job to break it into first name and last name parts. But using the lower() and upper() method was a good idea! Anyway, first show us how you'd take the input.
10th Dec 2018, 9:45 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
Okay, in line 1, the str() part is not required. The input is always treated as a string in Python. Next, using split(',') to get the two parts of the string is a great idea! But in lines 3 and 4, you're not using the name user entered. As it is, the code will always produce the same output no matter what the user provided. Directly replace line 2-4 by Firstname, Lastname = User.split(',') and it should work as expected. Let me know :)
10th Dec 2018, 10:05 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
What did you input? You have to input the first and the last name separated by comma, like kishalaya,saha Also, inside the input() function, it's pointless to write 'Ravi Srivastava'. That's not where we input stuff, that part is for prompting the user to input. You can use something like "Enter first and last name separated by comma: ". Finally, the space won't automatically appear between the two names. To ensure that, we'd need Fullname = Firstname.upper() + ' ' + Lastname.lower()
10th Dec 2018, 10:22 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
I explained that in the last paragraph of my last post. Write Fullname = Firstname.upper() + ' ' + Lastname.lower() Also, I told you to assign the split input to Firstname and Lastname. It should look like Firstname, Lastname = Name.split(',') But you changed it to 'Ravi', 'Srivastava'. Do you not know how to input things on Sololearn?
10th Dec 2018, 12:12 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
You're welcome! Thank you for cooperating by sharing your code! 😊
10th Dec 2018, 1:26 PM
Kishalaya Saha
Kishalaya Saha - avatar
0
I don't know. I'm just a beginner
10th Dec 2018, 9:21 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
0
Any help for that Problem
10th Dec 2018, 9:26 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
10th Dec 2018, 9:39 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
0
https://code.sololearn.com/ccDBkvKB12fv/?ref=app
10th Dec 2018, 9:54 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
10th Dec 2018, 9:57 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
0
https://code.sololearn.com/ccDBkvKB12fv/?ref=app It showing some value error
10th Dec 2018, 10:15 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
0
https://code.sololearn.com/ccDBkvKB12fv/?ref=app What to do when we want Space between the result
10th Dec 2018, 10:41 AM
Thotla Thirupathi
Thotla Thirupathi - avatar
10th Dec 2018, 12:59 PM
Thotla Thirupathi
Thotla Thirupathi - avatar
0
In line 3, you don't have the space inside the quotes. ' ' (with space) '' (without space) See the difference?
10th Dec 2018, 1:03 PM
Kishalaya Saha
Kishalaya Saha - avatar
0
Also, on Sololearn, the text inside input 'Enter Firstname and Lastname seperated by comma:' is not displayed at the time of taking the inputs. But on a real compiler it'd work fine.
10th Dec 2018, 1:06 PM
Kishalaya Saha
Kishalaya Saha - avatar
0
Thank you for being helpful ✌✌
10th Dec 2018, 1:08 PM
Thotla Thirupathi
Thotla Thirupathi - avatar
0
https:// code.sololearn.com/cSCQyM5DKeaz/?ref=app New problem...
10th Dec 2018, 4:49 PM
Thotla Thirupathi
Thotla Thirupathi - avatar