I always use the class Counter when i need to check if something repeats
Before starts to work on the input i always normalized it first
In this case i prefer to use regex to substitute hypens and spaces at once instead of using the method replace twice, like this: text.replace("-", "").replace("-", "")
A few tips:
Every time i need/want to do a challenge that need loop or repetitive tasks i always ask myself:
Can i use some of the standard libraries of python to solve this?
The big brain move on my approach was the use of Counter class, this class have a lot useful methods such as subtract, add, and get the most_common letter form the input.
Heyyyyyyyyy Rafael ;)
Thank you for sharing your code and your great approach in my Post.
I appreciate it
But if you test your program with a string like:
abc=is_isogram("A a B C)
print(abc)
the program will
__return : True__
but we need to get False cuz there's to letter (A, a).
Finally your comment was so helpful for me cuz I think I really need to change some of my approach in my coding routine like using standard libraries more and etc.
Thanks for giving a light in my jourrney.
Hi Banji, you've done a nice work on this challenge, congratulations :)
Here's my approach:
My considerations:
Counter
when i need to check if something repeatsregex
to substitute hypens and spaces at once instead of using the methodreplace
twice, like this:text.replace("-", "").replace("-", "")
A few tips:
Every time i need/want to do a challenge that need
loop
or repetitive tasks i always ask myself:Then i check the itertools, and the collections packages.
The big brain move on my approach was the use of Counter class, this class have a lot useful methods such as
subtract
,add
, and get themost_common
letter form the input.Heyyyyyyyyy Rafael ;)
Thank you for sharing your code and your great approach in my Post.
I appreciate it
But if you test your program with a string like:
the program will
__return : True__
but we need to get False cuz there's to letter (A, a).
Finally your comment was so helpful for me cuz I think I really need to change some of my approach in my coding routine like using standard libraries more and etc.
Thanks for giving a light in my jourrney.
Keep Moving Forward ツ
Code with 💛
🅑🅐🅝🅙🅘
I didn't see this case, we can fix this normalizing even more the input with
.lower()
and it will work just fine.I'm glad to help.