Im working with strings in python and i got an strange problem i cant explain.
My code:
print(tuple_data[11])
potting_time = tuple_data[11].split("_")[1].removesuffix('min')
print(potting_time)
if potting_time == '0':
print('is 0')
else:
print('else')
print(type(potting_time))
print(len(potting_time))
The output
Material=This_Omin
O
else
<class 'str'>
1
But if I copy the output 0 from print(potting_time) and replace the '0' at if potting_time == '0': with it and write '' by myself the output is ‘is 0’.
I thought about ' ' but the len() is 1
>Solution :
Look closely at your inputMaterial=This_Omin . You are testing for the character before min to be a 0 when in fact it is O
So to correct your code and get the result you expect change the line of code if potting_time == '0': to read if potting_time == 'O':.