CodePudding user response:
Def test (myList) :New_List=[]
For num in myList:
Try:
Num=int (num)
# base
If num % 2==1:
New_num=num * * 2-1
# even
The else:
New_num=num * * 2
Except:
Print (" input the correct array ")
Return "over"
New_List. Append (new_num)
Return new_List
CodePudding user response:
Random if you
Import the random as R
# returns the random number from a list [1, 2, 3, 4]
Ran_num=R.c hoice ([1, 2, 3, 4])
CodePudding user response:
Li=[1, 2, 3, 4]Li=[I * * 2/2 if (I % 2) else I * * 2 for I in li]
Print (li)
CodePudding user response:
Method one:Please look at the code