so my code has a lot of if statements:
rnrp += 1
if a100 == b100:
rnrp += 1
if a10 == b10:
rnrp += 1
if a1 == b1:
rnrp += 1
and:
if b1000 == a100:
rnwp += 1
break
if b1000 == a10:
rnwp += 1
break
if b1000 == a1:
rnwp += 1
break
while true:
if b100 == a1000:
rnwp += 1
break
if b100 == a10:
rnwp += 1
break
if b100 == a1:
rnwp += 1
break
while true:
if b10 == a1000:
rnwp += 1
break
if b10 == a100:
rnwp += 1
break
if b10 == a1:
rnwp += 1
break
while true:
if b1 == a1000:
rnwp += 1
break
if b1 == a100:
rnwp += 1
break
if b1 == a10:
rnwp += 1
break
as you can see this is a lot of if statements, the first is fine, but the second needs improvements. Also what the second code is trying to accomplish is checking each place of b (100's place, 100's place, 10's place etc..) matches any of the places of a. How can I shrink the amount of if statement's in the second part of the code? this post has been answered by jasonharper (I cant find the button as of right now so I'm just putting it in the question) thanks!!
if,elif... instead.while True:block, with threeifs, could be replaced byif/elif/elif, getting rid of all thebreaks. They could be further shortened by writingif b1000 in (a100, a10, a1): rnwp += 1.