~1 min read 0 comments

So I won’t forget how to write code in Python, I try to create a corresponding Python code for most of the JavaScript exercises I do. Here, I write a function that returns true or false if a word is an isogram (a word that doesn’t have repeat characters), in both Python and JavaScript.


var isIsogram = function(word) {
  var splitWord = word.split("");
  var uniqueLetters = [];
  splitWord.forEach(function(letter) {
    if (!uniqueLetters.includes(letter)) {
  return uniqueLetters.length === splitWord.length;

// I was trying to use `Set()` here but couldn't make the code work. I still have to really understand this method.


def is_isogram(word):
    letters = list(word)
    unique_letters = set(letters)
    return len(unique_letters) == len(letters)