Mar-15-2018, 12:09 AM
Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number.
['1 2 3 4 5 6 7']
('1 2 3 4 5 6 7',)
Please add some numbers in a row: 1234567
['1234567']
('1234567',)
it doesn't split and it doesn't separate elements with comma. Even when I remove comma from the split function it's giving me the same outcome.
I also tried to convert input string into integer with
values = input("Please add some numbers in a row: ") l = values.split(",") t = tuple(l) print(l) print(t)Please add some numbers in a row: 1 2 3 4 5 6 7
['1 2 3 4 5 6 7']
('1 2 3 4 5 6 7',)
Please add some numbers in a row: 1234567
['1234567']
('1234567',)
it doesn't split and it doesn't separate elements with comma. Even when I remove comma from the split function it's giving me the same outcome.
I also tried to convert input string into integer with
values = int(input("Please add some numbers in a row: "))but in that case I receive a value error. Could you explain me why?