I am having a bit of trouble removing one extra letter that is constantly popping up in my two lines, after my program evaluated all the numbers.
What it Should Produce:
How many steps did Nick take forwards: 4
How many steps did Nick take backwards: 2
How many steps did Bill take forwards: 5
How many steps did Bill take backwards: 3
How many steps were needed to finish the game: 13
Nick FFFFBBFFFFBBF = 5 paces from the start
Bill FFFFFBBBFFFFF = 7 paces from the start
Bill is Ahead after 13 steps
What it Does Produce:
How many steps did Nick take forwards: 4
How many steps did Nick take backwards: 2
How many steps did Bill take forwards: 5
How many steps did Bill take backwards: 3
How many steps were needed to finish the game: 13
Nick FFFFBBFFFFBBFB = 5 paces from the start
Bill FFFFFBBBFFFFFB = 7 paces from the start
Bill is Ahead after 13 steps
In the grand scheme of things, this issue isn't a huge deal, as the rest of the program works fine, but if anyone has a solution for this, I am all ears.
My Code:
#Enter how many steps Nick and Bill went forward and backward, and how many paces are needed to finish the game
A = int(input("How many steps did Nick take forwards: "))
B = int(input("How many steps did Nick take backwards: "))
C = int(input("How many steps did Bill take forwards: "))
D = int(input("How many steps did Bill take backwards: "))
S = int(input("How many steps were needed to finish the game: "))
#Counters to track how far Nick and Bill go, and how many paces they made to finish the game
counter = 0
counter2 = 0
paces = 0
paces2 = 0
#Check how many steps Nick and Bill made, and how many paces he took
print("\nNick")
while(counter < S):
F = 0
while(F < A):
print("F", end="")
F = F + 1
paces = paces + 1
counter = counter + 1
if counter >= S:
break
b = 0
while(b < B):
print("B", end="")
b = b + 1
paces = paces - 1
counter = counter + 1
if counter >= S:
break
print(" =",paces + 1 ,"paces from the start")
#Check how many steps Bill made, and how many paces he took
print("\nBill")
while(counter2 < S):
F2 = 0
while(F2 < C):
print("F", end="")
F2 = F2 + 1
paces2 = paces2 + 1
counter2 = counter2 + 1
if counter2 >= S:
break
b2 = 0
while(b2 < D):
print("B", end="")
b2 = b2 + 1
paces2 = paces2 - 1
counter2 = counter2 + 1
if counter2 >= S:
break
print(" =",paces2 + 1 ,"paces from the start")
#Display who won, and by how much
if paces > paces2:
print("\nNick is Ahead after",S,"steps")
elif paces < paces2:
print("\nBill is Ahead after",S,"steps")
elif paces == paces2:
print("\nBill and Nick are Tied after",S,"steps")