Check if a string has the same amount of 'x' and 'o'. The method must return a Boolean value and must not be case-sensitive. The string can contain any char.
For further actions, you may consider blocking this person and/or reporting abuse
Check if a string has the same amount of 'x' and 'o'. The method must return a Boolean value and must not be case-sensitive. The string can contain any char.
For further actions, you may consider blocking this person and/or reporting abuse
Need a better mental model for async/await?
Check out this classic DEV post on the subject.
Sam Ternent -
Jonas -
Will -
Przemyslaw Jan Beigert -
Once suspended, iltw1n will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, iltw1n will be able to comment and publish posts again.
Once unpublished, all posts by iltw1n will become hidden and only accessible to themselves.
If iltw1n is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to José Oscátegui.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag iltw1n:
Unflagging iltw1n will restore default visibility to their posts.
Top comments (12)
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 !
In Haskell, with what I thought was kind of a neat method:
As a javascript one-liner:
A simple solution with Rust.
Python to the rescue !
output
Time for a Go kata you say?
play.golang.org/p/n8q9BYrsW4a
Rust Solution.
Ruby Solution!