If I want to define a sequence results of the form PIPPPINNNIPPPPPPPPPPINN
for the following planets elements: AXDDCCCCSSDFQWEAACCCXXX, porty: ASDF, y, Nick: ZXCV
Where P and N are the initials of the player leading the other, and I is the positioner when both players are tied.
The code with which you started the resolution is this:
porty = input('').upper()
nick = input('').upper()
planetas = input('').upper()
resultado=""
cont1=0
cont2=0
for resultado in planetas:
for n in nick:
if resultado == n:
cont1 = cont1+1
for resultado in planetas:
for p in porty:
if resultado ==p:
cont2 = cont2+1
if (cont1 > cont2):
resultado +="P"
else:
if (cont1 > cont2):
resultado +="N"
else:
resultado +="I"
print(resultado)
resultadois used both as a loop variable and as the final result. I think you should use a separate loop variable (planeta?). The way this is writtenresultadois overwritten each time through the loop.