Entry, in the same line, of a string without spaces and one with spaces

0

My program asks that, on entry, on the same line, there is a string with no spaces name, the name of the depositor, and a string that can contain spaces desc, the description of the object deposited. So, after that I create a dictionary to relate the name and the object.

Exit: Ana Blue Bag

However, as I have done, it is only possible to enter a word at the location of the object description. How do I enter more than one word in desc ??

How I did it:

dic={}

nome,desc=input().split()

dic.update({nome:desc})
    
asked by anonymous 06.06.2017 / 16:36

1 answer

0

You can change the split to break only on the first occurrence

How will your code stay:

dic={}

nome,desc=input().split(" ", 1)

dic.update({nome:desc})
    
06.06.2017 / 16:46