Advertisement
SetKaung

Class10_Assign1

Feb 20th, 2024
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. def ClassifyDataType(myList):
  2.     intList = []
  3.     strList = []
  4.     scList = []
  5.     for element in myList:
  6.         if type(element) is int:
  7.             intList.append(element)
  8.         elif type(element) is str:
  9.             if element.isalnum():
  10.                 strList.append(element)
  11.             else:
  12.                 scList.append(element)
  13.                
  14.     return intList,strList,scList
  15.  
  16. def ListofDivisibleBy3(numList):
  17.     output = []
  18.     for element in numList:
  19.         if element % 3 == 0:
  20.             output.append(element)
  21.     return output
  22.  
  23. def KeepTwoDup(numList):
  24.     outList = []
  25.     seen1 = []
  26.     for element in numList:
  27.         if (element in outList) and (element in seen1):
  28.             continue
  29.         elif (element in outList):
  30.             seen1.append(element)
  31.             outList.append(element)
  32.         else:
  33.             outList.append(element)
  34.     return outList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement