首页 > 解决方案 > TypeError: 'car' is an invalid keyword argument for print()

问题描述

I don't understand the error. Here is the code,

car = 'mercedes'
print("Is car = 'mercedes'? I predict True.")
print(car = 'mercedes')
print("\nIs car = 'audi'? I predict False.")
print(car = 'audi')

When I try to run this the error is

TypeError: 'car' is an invalid keyword argument for print().

标签: python

解决方案


if you want to check for equality then use == instead of =

print(car == 'mercedes')


推荐阅读