Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def readfile(file):
- with open(file,"r",encoding="utf-8") as read:
- templist=list()
- arrayofcucc=list()
- for row in read:
- templist=row.strip().split(",")
- for i in range(0,len(templist),1):
- if templist[i].isnumeric() == True:
- arrayofcucc.append(int(templist[i]))
- else:
- print("The file contains text or special character that won't being listed")
- return arrayofcucc
- def checkeven(lst):
- return [str(a)+" even" if a %2 ==0 else str(a)+" odd" for a in lst ]
- lstdefault=list()
- lstdefault=readfile("num.txt")
- lst = [1,4,10,12,15]
- choice=input("From file or forced? 1) 2)")
- if choice=="1":
- print(checkeven(lstdefault))
- elif choice=="2":
- print(checkeven(lst))
- else:
- print("No array or file selected")
- #__________________________________
- # Txt contain any length of number separated with ","
- 1,2,3,5,111,122,1110
- 40,20,30
- 100,200,300
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement