Like title says, I am supposed to find the number of unique characters in a string. Here's the catch, no arrays or even while loops (although for loop can accomplish this). I have tried but I can't seem to do it without writing a bunch of ridiculous if-el statements under a for loop checking each char value against each other.
Inside the Python For Loop, we used the If statement to check whether any character in a string is equal to the given character or not. If true, then count = count + 1. if(t == t) – Condition is True. if(u == l) – Condition is false.
Use this:
len(set("stackoverflow")) # returns 12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With