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
21 Respostas
+ 2
Please show your attempt! We're discouraged to write the whole code for others. I hope you understand. Thanks!
+ 2
For Sure Kishalaya Saha
+ 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.
+ 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.
+ 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 :)
+ 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()
+ 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?
+ 1
You're welcome! Thank you for cooperating by sharing your code! 😊
0
I don't know. I'm just a beginner
0
Any help for that Problem
0
https://code.sololearn.com/ccDBkvKB12fv/?ref=app
0
https://code.sololearn.com/ccDBkvKB12fv/?ref=app
It showing some value error
0
https://code.sololearn.com/ccDBkvKB12fv/?ref=app
What to do when we want Space between the result
0
https://code.sololearn.com/ccDBkvKB12fv/?ref=app
Once check it out....
0
In line 3, you don't have the space inside the quotes.
' ' (with space)
'' (without space)
See the difference?
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.
0
Thank you for being helpful ✌✌
0
https:// code.sololearn.com/cSCQyM5DKeaz/?ref=app
New problem...