Search In
• More options...
Find results that contain...
Find results in... # My program states "not all arguments converted during string formatting"

Don't forget to use the forum's code tag:

```a =1
while a==1:
Numcas = int(input("How many cases do you have?: "))
countcas = 1
state = a = input('Enter the amount of columns and rows in your game: ')
h = a.split(",")
coltotal = int(h)
rowtotal = int(h)
if (2<=coltotal<=1000 and 2<=rowtotal<=1000):
while (countcas <= Numcas):
question2 = 'Enter the starting position in the case #{}: '
positionst = input(question2.format(countcas))
position = positionst.split(",")
colstart = int(position)
rowstart = int(position)
question4 = 'Enter the finishing position number in the case #{} '
positionend= input(question4.format(countcas))
positionen = positionend.split(",")
colend = int(positionen)
rowend = int(positionen)
countcas+=1
seqcount = 1
if positionst % 2 == 0 and positionst % 2 == 0 and positionend % 2 ==0 and positionend % 2 ==0:
print ("TRUE")
if positionst % 2 !=0 and positionst % 2 !=0 and positionend % 2 !=0 and positionend % 2 !=0:
print ("TRUE")
if positionst % 2 !=0 and positionst % 2 ==0 and positionend % 2 !=0 and positionend % 2 ==0:
print ("TRUE")
if positionst % 2 ==0 and positionst % 2 !=0 and positionend % 2 ==0 and positionend % 2 !=0:
print ("TRUE")
else:
print ("FALSE")```

The issue is that positionst and positionend are strings. This causes the % operator to be interpreted as string interpolation. You probably want to replace positionst with colstart, positionst with rowstart, etc... Those are your integers which will have % do the modulus operation like I think you are expecting.

Feel free to ask more questions.

## Recommended Posts

Posted · Original PosterOP

Hello, I've been working on a python code to trace the movement of the bishop in a chess game. I'm working with odd and even coordinates to know if the bishop can move or not, and it can move more than once to reach the final coordinate.

My code does not work when it comes to the 'if' statement and it states "not all arguments converted during string formatting"...I've tried adding 'int' and stuff, but it's just not working..Help!!

Code:

a =1
while a==1:
Numcas = int(input("How many cases do you have?: "))
countcas = 1
state = a = input('Enter the amount of columns and rows in your game: ')
h = a.split(",")
coltotal = int(h)
rowtotal = int(h)
if (2<=coltotal<=1000 and 2<=rowtotal<=1000):
while (countcas <= Numcas):
question2 = 'Enter the starting position in the case #{}: '
positionst = input(question2.format(countcas))
position = positionst.split(",")
colstart = int(position)
rowstart = int(position)
question4 = 'Enter the finishing position number in the case #{} '
positionend= input(question4.format(countcas))
positionen = positionend.split(",")
colend = int(positionen)
rowend = int(positionen)
countcas+=1
seqcount = 1
if positionst % 2 == 0 and positionst % 2 == 0 and positionend % 2 ==0 and positionend % 2 ==0:
print ("TRUE")
if positionst % 2 !=0 and positionst % 2 !=0 and positionend % 2 !=0 and positionend % 2 !=0:
print ("TRUE")
if positionst % 2 !=0 and positionst % 2 ==0 and positionend % 2 !=0 and positionend % 2 ==0:
print ("TRUE")
if positionst % 2 ==0 and positionst % 2 !=0 and positionend % 2 ==0 and positionend % 2 !=0:
print ("TRUE")
else:
print ("FALSE")

##### Share on other sites

Don't forget to use the forum's code tag:

```a =1
while a==1:
Numcas = int(input("How many cases do you have?: "))
countcas = 1
state = a = input('Enter the amount of columns and rows in your game: ')
h = a.split(",")
coltotal = int(h)
rowtotal = int(h)
if (2<=coltotal<=1000 and 2<=rowtotal<=1000):
while (countcas <= Numcas):
question2 = 'Enter the starting position in the case #{}: '
positionst = input(question2.format(countcas))
position = positionst.split(",")
colstart = int(position)
rowstart = int(position)
question4 = 'Enter the finishing position number in the case #{} '
positionend= input(question4.format(countcas))
positionen = positionend.split(",")
colend = int(positionen)
rowend = int(positionen)
countcas+=1
seqcount = 1
if positionst % 2 == 0 and positionst % 2 == 0 and positionend % 2 ==0 and positionend % 2 ==0:
print ("TRUE")
if positionst % 2 !=0 and positionst % 2 !=0 and positionend % 2 !=0 and positionend % 2 !=0:
print ("TRUE")
if positionst % 2 !=0 and positionst % 2 ==0 and positionend % 2 !=0 and positionend % 2 ==0:
print ("TRUE")
if positionst % 2 ==0 and positionst % 2 !=0 and positionend % 2 ==0 and positionend % 2 !=0:
print ("TRUE")
else:
print ("FALSE")```

The issue is that positionst and positionend are strings. This causes the % operator to be interpreted as string interpolation. You probably want to replace positionst with colstart, positionst with rowstart, etc... Those are your integers which will have % do the modulus operation like I think you are expecting.

Feel free to ask more questions.