Hector Harris
Hector Harris

Reputation: 15

Pylint checker: Format function is not called on a string

Code works fine in wing etc. Pylint isn't very happy with me keep getting the style error:

format function is not called on str (misplaced-format-function)

def print_daily_totals(rainfalls):
    '''t'''
    day = 0
    return_list = []
    for row in rainfalls:
        total = 0
        for i in row:
            total += i
        return_list.append(total)
    for value in return_list:
        print("Day {} total: {}").format(day, value)

rain = [ 
      [0, 7, 9],
      [4, 6, 2],
      [0, 0, 0],
      [10, 23, 5],
      [20, 0, 0]
]
print_daily_totals(rain)

Upvotes: 0

Views: 142

Answers (1)

dspencer
dspencer

Reputation: 4461

You have a misplaced bracket:

print("Day {} total: {}").format(day, value)

should be

print("Day {} total: {}".format(day, value))

Though I find it hard to believe that the code works normally, as you suggest. print returns None and has no method format.

Upvotes: 3

Related Questions