Ad

changes

  • Internet username checker
  • Using custom check function
  • Cool -> Kool
  • Testcases have been brought back.
  • Removed comment about having lots of edge cases.

I really hope these improvements will help the development of the you_are_cool/you_are_kool/youAreCool/youAreKool(coming soon) programs in the future. Thanks for everyone who has supported the development of this program. Thanks a lot.

Code
Diff
  • # if and then a series of elif's is FASTER.
    
    def you_are_kool(n):
        if not isinstance(n, str):
            return "Wait, so your name ISN'T a string of text?! That's wild!"
        n = n.strip()
        if not n:
            return "There is no name, so I'm not complimenting you. LOL..."
        elif len(n) > 100:
            return "Man, you have an insanely long name! Do people call you by your full name or just a nickname?"
        elif n.isdigit():
            return "Are you sure? That looks like a number. Unless you're secretly a robot with a numerical name!"
        elif any(char in n for char in "!@#$%^&*()_+=[]\\/<>,.`~"):
            return f"Hello {n}, you are very kool! But is that your internet name?!"
        return f"Hello {n}, you are very kool!"
    
    
    • def you_are_cool(n="Taki"):
    • # if and then a series of elif's is FASTER.
    • def you_are_kool(n):
    • if not isinstance(n, str):
    • return "Wait, so your name ISN'T a string of text?! That's wild!"
    • n = n.strip()
    • if not n:
    • return "There is no name, so I'm not complimenting you. LOL"
    • if len(n) > 100:
    • return "There is no name, so I'm not complimenting you. LOL..."
    • elif len(n) > 100:
    • return "Man, you have an insanely long name! Do people call you by your full name or just a nickname?"
    • if n.isdigit():
    • elif n.isdigit():
    • return "Are you sure? That looks like a number. Unless you're secretly a robot with a numerical name!"
    • return f"Hello {n}, you are very cool!"
    • # edge case go BRRR
    • elif any(char in n for char in "!@#$%^&*()_+=[]\\/<>,.`~"):
    • return f"Hello {n}, you are very kool! But is that your internet name?!"
    • return f"Hello {n}, you are very kool!"

more tests and more edge case testing lol

Code
Diff
  • def you_are_cool(n):
        if not isinstance(n, str):
            return "Wait, so your name ISN'T a string of text?! That's wild!"
        elif n.strip() == "":
            return "There is no name, so I'm not complimenting you. LOL"
        elif len(n.strip()) > 100:
            return "Man, you have an insanely long name! Do people call you by your full name or just a nickname?"
        elif n.strip().isdigit():
            return "Are you sure? That looks like a number. Unless you're secretly a robot with a numerical name!"
        else:
            return "Hello " + n.strip() + ", you are very cool!"
        
    # edge case go BRRR
    • def your_name(n="Taki"):
    • return f"Hello {n}, you are very kool!"
    • def you_are_cool(n):
    • if not isinstance(n, str):
    • return "Wait, so your name ISN'T a string of text?! That's wild!"
    • elif n.strip() == "":
    • return "There is no name, so I'm not complimenting you. LOL"
    • elif len(n.strip()) > 100:
    • return "Man, you have an insanely long name! Do people call you by your full name or just a nickname?"
    • elif n.strip().isdigit():
    • return "Are you sure? That looks like a number. Unless you're secretly a robot with a numerical name!"
    • else:
    • return "Hello " + n.strip() + ", you are very cool!"
    • # edge case go BRRR
Fundamentals
Strings

This code now shows how reversing a string works. Reversing a string is just changing the order in which a string is read. New test cases have been added too. If you really wanted the shortest code possible, I am very sorry to upset you. But I can change it if you want to.

Code
Diff
  • def flip_str(string):
        idx = -1  # Start index for reversing
        new_string = ""  # Create an empty string to store the reversed string
        for val in string:
            new_string += string[idx]  # Add characters from the original string in reverse order
            idx -= 1  # Move to the previous character in the original string
        return new_string
    • reverse_string = lambda string: "".join(reversed(string))
    • def flip_str(string):
    • idx = -1 # Start index for reversing
    • new_string = "" # Create an empty string to store the reversed string
    • for val in string:
    • new_string += string[idx] # Add characters from the original string in reverse order
    • idx -= 1 # Move to the previous character in the original string
    • return new_string