Skip to content

Instantly share code, notes, and snippets.

@boxpositron
Last active December 11, 2018 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boxpositron/87f8dd8a6e180bd10f92697aa878e2fa to your computer and use it in GitHub Desktop.
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
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