How to get input from user, then check if the multiple lists matches the input

Viewed 63

I'm a fairly beginner in Py, tho I am trying to automate a task in something, we are dubbing a webtoon series, and we need to train since we are quite a lot, I need a program, that check the user input for a number, then check multiples list (episode 1 (3) ) for the number of characters in it.

I also need if someone is willing to help more, to do this with name, I nearly got it, then got stuck, and I got mad so I deleted everything, but ht code was bad, so no remorse. so you put a bunch of names, and it will output the episodes with these names in it.

ep_1 = [3]    these are the numbers of character in an episode
ep_2 = [1]
ep_3 = [1]
ep_4 = [1]
ep_5 = [3]
eps = ep_1.extend(ep_2 + ep_3 + ep_4)

print("version : 1.0 : Dispo j'usqu'a l'episode 50")

print(" ")
print(" ")
print(" ")

print("Noms des personnages a utiliser : john isen arlo doc directeur elaine sera cecile blyke")
print(" ")
print(" ")
print(" ")

choix = input("Numbers of characters, or names of characters ?")

if choix := ("nombre"):
    nombre_persos = int(input("how many characters ? : "))
    if nombre_persos in eps:
        print("oui")    this just help me verify the if statement, i just dont know what to do next, and even if im doing anything good
2 Answers

You can use map{}. Something like this:

n = int(input())
for episode,characters in episodes.items():
    if n == characters:
        print(episode)

You can use enumerate. Here is the code:

ep_1 = [3]
ep_2 = [1]
ep_3 = [1]
ep_4 = [1]
ep_5 = [3]
eps = ep_1 + ep_2 + ep_3 + ep_4

print("version : 1.0 : Dispo j'usqu'a l'episode 50")

print(" ")
print(" ")
print(" ")

print("Noms des personnages a utiliser : john isen arlo doc directeur elaine sera cecile blyke")
print(" ")
print(" ")
print(" ")

choix = input("Numbers of characters, or names of characters ?")

if choix == ("nombre"):
    nombre_persos = int(input("how many characters ? : "))
    if nombre_persos in eps:
        print("oui")
        eps2 = eps
        for (i, item) in enumerate(eps2, start=1):
            if item == nombre_persos:
                print('ep_'+str(i))

And see this for enumerate: https://docs.python.org/3/library/functions.html#enumerate

Related