Ad
  • Custom User Avatar

    not a suggestion

  • Custom User Avatar

    I see several issues with your code:

    1. You modify the input: the line 'string="isIsogram"' is changing your input. The string you iterate should be the one you get in the parameter.
    2. You modify the iterated string from inside the loop: Regardless the fact that the assignment is unwanted, the location of the assignment, inside the loop that iterates the string is a (very) bad practice in general. Take care not to do that.
    3. Algorithm efficiency (I home I'm not talking chinese here):
      • You iterate the string, which means the loop iterates all its characters (a total of n chars.)
      • Then, inside you use the built in 'count' function, which also iterates the string.
      • Thus, in the worst case (when the string is an isogram) your efficiency is O(n2), which is considered highly inefficient. Think of a way to improve that (you can get to O(n).)
  • Custom User Avatar

    tested you code and it returned False,but it gave me one i instead two (i,I)

    i and its count 1
    s and its count 2
    False

    i would converted the input string into either lowercase or upperase and then do the count ( in this test the letter case does't matter)
    also, you only check one condition --> if chars.islower(), so the code will miss (upper case I)

  • Custom User Avatar

    i have a doubt on this test case
    isIsogram

    this should return false, since there are repeating letter (s)

    but it fails, dont know why