Last active
December 11, 2018 10:29
-
-
Save boxpositron/87f8dd8a6e180bd10f92697aa878e2fa to your computer and use it in GitHub Desktop.
Write a program which accepts a sequence of comma-seperated numbers from console and generate a list and a tuple which contains every number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
''' | |
Write a program which accepts a sequence of comma-seperated | |
numbers from console and generate a list and a tuple which | |
contains every number | |
''' | |
def create_list(data): | |
numbers = data.split(',') | |
return list(numbers) | |
def create_tuple(data): | |
numbers = data.split(',') | |
return tuple(numbers) | |
def get_data(): | |
query = 'Please enter a sequence of comma-seperated numbers : '; | |
if sys.version_info[0] < 3: | |
values = str(raw_input(query)) | |
else: | |
values = str(input(query)) | |
return values | |
def test(): | |
data = '34,67,55,33,12,98' | |
data_list = create_list(data) | |
data_tuple = create_tuple(data) | |
print('{0} \n\n {1}'.format(data_list, data_tuple)) | |
if __name__ == '__main__': | |
data = get_data() | |
data_list = create_list(data) | |
data_tuple = create_tuple(data) | |
print('{0} \n\n {1}'.format(data_list, data_tuple)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment