Is a range different from an integer?

The below code is throwing the following error.

Is it because a range is not an integer? Should I refrain from using range and boolean values?

File "script.py", line 3, in add_exclamation
    if range(len(word)) > 20:
TypeError: unorderable types: range() > int()
# Write your add_exclamation function here:
def add_exclamation(word):
  if range(len(word)-1) >= 20:
    return word 
  else:
    for i in range(len(word)):
      word = word + "!"
    return word 
# Uncomment these function calls to test your function:
print(add_exclamation("Codecademy"))

Precisely. A range is an object of type ‘range’. Comparisons require matching types.

1 Like