Advertisement
Adehumble

Weekly challenge

Mar 1st, 2020
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. print("\t\tWEEKLY CODING CHALLENGE")
  2. print("\n")
  3. print("This program is written to return a number list whose length is up to 15 or more without repetition of its items\nHAPPY CODING!")
  4. print("\n")
  5.  
  6.  
  7. #FUNCTION PROGRAM
  8. def duplicate(number):
  9.     answer=[]
  10.     if len(number)<15:
  11.         print("The length of your number choices is not up to 15. Please, try again!") 
  12.     else:
  13.         for n in number:
  14.             if n not in answer:
  15.                 answer.append(n)
  16.         print("Your list of number choices are:",number)
  17.         print("\n")
  18.         print("The list of those numbers without repetition is:", answer)
  19.         print("\n")
  20.         print("The length of the new list without repetition is:", len(answer))
  21.    
  22.  
  23. #MAIN PROGRAM
  24. number_list=[]
  25. num_list=[]
  26. print("You are about to be prompted for your number choices. Remember, you must enter 'Done' when you are okay with your choices.")
  27. print("\n")
  28. while True:
  29.     #using capitalize() to format the input wont allow us to run into trouble in case the user enter "Done" in diferrent cases.
  30.     num=input("Please, enter those numbers one after the other: ").capitalize()
  31.     if num=="Done":
  32.         break
  33.     else:
  34.         num_list.append(num)
  35.        
  36. #The line below will generate an integer list
  37. number_list=[int(i) for i in num_list]
  38.  
  39. #The line below will also sort the items.in ascending order
  40. number_list.sort()
  41.  
  42. #Lets call our function to action!
  43. duplicate(number_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement