Exercise 42

Write a python program that asks the user to enter numbers separated by semicolons ';' and generates a list make up of the entered numbers.

Solution

# ask user to enter som numbers
numbers = input("Enter some numbers separated by semicolons : ")

# creating a list from entered numbers
listNumbers = numbers.split(';')

# disply result
print("List of entered numbers : " , listNumbers)
# Example for the numbers entered : 10 ; 25 ; 37 ; 2 ; 11
# The output is : List of entered numbers :  ['10 ', ' 25 ', ' 37 ', ' 2 ', ' 11']





 

Younes Derfoufi
my-courses.net

Leave a Reply