Saturday, February 6, 2016

Python program to store unique user input values in a set

#A program to accept user inputs and stores them without duplicate values in python.

mySet = set()
#number of values allowed to be stored in the set
n = 5
while len(mySet) < n :
    foo = float(input("Enter value:"))
    foo = round(foo)
    mySet.add(foo)

#print the unsorted set
print(mySet)

No comments:

Post a Comment