New to python. I've got an assignment where I have to generate a random list of numbers between -10 and 30 and then proceed to call odds and evens from the list. So far I've got this, but I have no idea how to proceed and how to make it actually work properly. Also I need to figure out how to also check positive and negative numbers from the list, but currently I'm just stuck at odds and evens.
import random
def Osio7():
randomlist = random.sample(range(-10, 30), 40)
print(randomlist)
def odd(randomlist):
odd = []
for i in range(1, randomlist*2+1):
odd.append(i)
return Osio7
def even(randomlist):
even = []
for i in range(1, randomlist % 2+1):
even.append(i)
return Osio7
Aucun commentaire:
Enregistrer un commentaire