Thank you for that! I had not noticed it. Yes, there are some awesome string methods in Python, but I didn't use any of them here because I wanted to finish the count(s) in one pass of the string. Doing a .lower() and then counting might involve two passes of the same string.
I suggested it to reduce your conditions, lowering the string before checking would have allowed you to only check for o and x for example. This way you would have one pass on the string and a more concise condition :)
Do you mean lowering the string before the loop or lowering the character in the loop before checking whether it is an 'x' or 'o'?
Lowering the string before the loop would involve one complete pass of the string. And then you would have to iterate through the string, again, to count the frequencies.
Lowering just the character inside the loop, is just equivalent to the if condition, right? I am probably saving on a function call by not calling .lower() on the character.
Python solution -
Thank you @Pierre for pointing out the error.
Hey @ganeshtata !
I think you missed an uppercase in your
elif
:)instead of
To dig a little deeper, I suggest you to see some very useful string methods in Python !
Thank you for that! I had not noticed it. Yes, there are some awesome string methods in Python, but I didn't use any of them here because I wanted to finish the count(s) in one pass of the string. Doing a
.lower()
and then counting might involve two passes of the same string.I suggested it to reduce your conditions, lowering the string before checking would have allowed you to only check for
o
andx
for example. This way you would have one pass on the string and a more concise condition :)Do you mean lowering the string before the loop or lowering the character in the loop before checking whether it is an 'x' or 'o'?
.lower()
on the character.Oh right, nevermind !