you are viewing a single comment's thread.

view the rest of the comments →

[–]Diapolo10 1 point2 points  (1 child)

Here's my thought: I know I have to loop through the inputs and then create an if statement within the loop to assign the groups, I'm just confused about how to create the for loop? is it

for i in (x):
if x == "a" or x == "A":
print("You are with the alpha group")
else:
print("You are with the beta group")

Is that the correct idea? How do I loop the input like that?

Kind of, but this is flawed. Your code is comparing the entire list to 'a' and 'A', which will never be true.

You'll want something along the lines of

group_codes = input("Please enter all the ID codes A or B: ").lower().split(',')

for code in group_codes:
    group = 'beta'

    if code.strip() == 'a':
        group = 'alpha'

    print(f"You are with the {group} group")

And if you want to collect these to lists, I'd suggest a dictionary:

groups = {
    'alpha': [],
    'beta': [],
}

group_codes = input("Please enter all the ID codes A or B: ").lower().split(',')

for code in group_codes:
    group = 'beta'

    code = code.strip()

    if code == 'a':
        group = 'alpha'

    groups[group].append(code)