from random import randint
rand = randint(0, 120000)
print(rand)
def toListInt(var):
if var == None:
return
try:
res = list(map(int, list(str(var))))
print('\ntoListInt Success!')
return res
except:
print('\ntoListInt Error!')
return
def EvenOnly(var):
if var == None:
return
res = list()
while len(var) > 0:
if var[0] % 2 == 0:
res.append(var[0])
var.pop(0)
else:
var.pop(0)
print('\nEvenOnly Success!')
return res
def OddOnly(var):
if var == None:
return
try:
res = list()
while len(var) > 1:
if var[0] % 2 == 1:
res.append(var[0])
var.pop(0)
else:
var.pop(0)
print('\nOddOnly Success!')
return res
except:
print('\nOddOnly Error!')
return
res1 = toListInt(rand)
print(res1)
res2 = EvenOnly(res1)
print(''.join(list(map(str, res2))))
res3 = OddOnly(res1)
print(''.join(list(map(str, res3))))
import copy
from random import randint
rand = randint(0, 120000)
print(rand)
def toListInt(var):
if var == None:
return
try:
res = list(map(int, list(str(var))))
print('\ntoListInt Success!')
return res
except:
print('\ntoListInt Error!')
return
def EvenOnly(var):
if var == None:
return
try:
res = list()
while len(var) > 0:
if var[0] % 2 == 0:
res.append(var[0])
var.pop(0)
else:
var.pop(0)
print('\nEvenOnly Success!')
return res
except:
print('\nEvenOnly Error!')
def OddOnly(var):
if var == None:
return
try:
res = list()
while len(var) > 1:
if var[0] % 2 == 1:
res.append(var[0])
var.pop(0)
else:
var.pop(0)
print('\nOddOnly Success!')
return res
except:
print('\nOddOnly Error!')
return
res1 = toListInt(rand)
print(res1)
res11 = copy.copy(res1)
res12 = copy.copy(res1)
res2 = EvenOnly(res11)
print(''.join(list(map(str, res2))))
res3 = OddOnly(res12)
print(''.join(list(map(str, res3))))