Let's take the example , s = "Six-Year- Old". replace('-', '') , replace(' ', '') will going to replace all -'s and spaces with empty character respectively. lower() will lowercase all charecters.
So, cleaned will be, cleaned = 'sixyearold'.
Now, set(cleaned) stores all unique characters of cleaned. So, if count of all unique characters is same as length of cleaned then all characters of cleaned are unique.
len(set(cleaned)) == len(cleaned) will be True if all characters of cleaned are unique, else False.
Let's take the example ,
s = "Six-Year- Old".replace('-', ''),replace(' ', '')will going to replace all-'s and spaces with empty character respectively.lower()will lowercase all charecters.So,
cleanedwill be,cleaned = 'sixyearold'.Now,
set(cleaned)stores all unique characters ofcleaned. So, if count of all unique characters is same as length ofcleanedthen all characters ofcleanedare unique.len(set(cleaned)) == len(cleaned)will beTrueif all characters ofcleanedare unique, elseFalse.Tnx Vidit Sarkar for your amazing explanation .
I appreciate that.
Keep Moving Forward ツ
Code with 💛
🅑🅐🅝🅙🅘