vendredi 13 octobre 2023

how do i choose randomly items from two different lists and display them together?

I want to generate new animals composed from elements from list1 and list2, e.g.: Sea-rat, Fire-horse, Nile-cat The mix should be generated randomly. Can someone point out, what Im doing wrong and why?

def new_animal():
    list1 = [ "Nile", "Sea", "Land", "Fire" ]
    list2 = [ "-rat", "-lion", "-cat", "-horse" ]
    list1 + list2
    return new_animal()
        
    import random
    random.choice(list1) + (list2)

    return new_animal()
    
def Zoo():
    new_animal = animal()
    print = "What animal is this?"
    answer = "That animal is a" + new_animal
    print(answer)

I believe i do something wrong with the part where i add lists, but i need only one element of each list... otherwise i believe my information flow is correct?




Aucun commentaire:

Enregistrer un commentaire