Q:

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

belongs to collection: Python Input and Output Exercises

0

Accept any three string from one input() call

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

Expected Output

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Hint:

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

Solution:

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a python program to use string.format() meth... >>
<< Write all content of a given file into a new file ...