so, ich möchte ein program mache das es 12 Listen mit Nummer hat und eine Input .Der Input soll mit allen 12 Listen vergleichen und print die Nummer die mit der Input übereinstimmen .
Beispiel:
input : 2 14 34 12 23 45
Erste liste : ["2", "14", "18", "28","40", "48"]
print 2 14
ich habe diesen code geschrieben :
Code: Alles auswählen
w = raw_input("give number: ").split()
a1 = ["2", "14", "18", "28","40", "48"]
b2 = ["5", "9", "17", "21", "32", "49"]
c3 = ["4", "18", "19", "30", "47", "49"]
d4 = ["9", "15", "25", "28", "39", "43"]
e5 = ["8", "11", "13", "25", "39", "48"]
f6 = ["3", "12", "13", "14", "31", "33"]
g7 = ["3", "12", "14", "23", "26", "45"]
h8 = ["1", "10", "12", "15", "18", "37"]
i9 = ["6", "7", "17", "38", "41", "44"]
j10 = ["1", "7", "14", "17", "27", "35"]
k11 = ["15", "23", "25", "26", "39", "48"]
l12 = ["5", "12", "14", "30", "41", "48"]
for a,b,c,d,e,f,g,h,i,j,k,l in zip(a1, b2, c3, d4, e5, f6, g7, h8, i9, j10, k11, l12):
if a in w :
print "(1)", a
elif b in w:
print "(2)", b
elif c in w:
print "(3)", c
elif d in w:
print "(4)", d
elif e in w:
print "(5)", e
elif f in w:
print "(6)", f
elif g in w:
print "(7)", g
elif h in w:
print "(8)", h
elif i in w:
print "(9)", i
elif j in w:
print "(10)", j
elif k in w:
print "(11)", k
else:
print "(12)", a
give number: 2 14 18 28
(1) 2
(1) 14
(1) 18
(1) 28
(8) 40
(12) 48
Kann jemand Bitte diese probleme lösung? danke!