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 "", 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 
    for i in range(len(word)):
      word = word + "!"
    return word 
# Uncomment these function calls to test your function:

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

1 Like