Python exercise need explanations | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python exercise need explanations

Q: Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers. Code: values = input("Input some comma seprated numbers : ") list = values.split(",") tuple = tuple(list) print('List : ',list) print('Tuple : ',tuple) Input some comma seprated numbers : 3,5,7,23 List : ['3', '5', '7', '23'] Tuple : ('3', '5', '7', '23') I understand how tuples function, can someone explain to me how lost was created in this exercise ?

28th Apr 2019, 9:29 PM
Tai
4 Answers
28th Apr 2019, 10:05 PM
Dima Makieiev
Dima Makieiev - avatar
+ 1
It is not recommended to use functions (e.g. list, tuple) as variable names as they can mess up with your code.
28th Apr 2019, 10:46 PM
Diego
Diego - avatar
0
Thanks a lot that was really helpful
28th Apr 2019, 10:11 PM
Tai
0
returns a list of strings after breaking the given string by the specified separator. http://net-informations.com/JUMP_LINK__&&__python__&&__JUMP_LINK/file/split.htm
27th Feb 2020, 6:37 AM
rahul kumar
rahul kumar - avatar