Write a python program to take three names as input from a user in the single input() function call.

Python / Fundamentals of Python

1274

Given Input:

Emma Jessa Kelly

Expected Output:

Enter three string Emma Jessa Kelly
Name1: Emma
Name2: Jessa
Name3: Kelly

Hints:

  • Ask the user to enter three names separated by space
  • Split input string on whitespace using the split() function to get three individual names

Program:

str1, str2, str3 = input("Enter three string").split()
print('Name1:', str1)
print('Name2:', str2)
print('Name3:', str3)

Output:

Enter three string Rumman Ansari Hello
Name1: Rumman
Name2: Ansari
Name3: Hello

This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.