# 錯誤示例
str = hello
format()
方法或者f-string來實現,如果直接將變量放在字符串中,會導致錯誤。# 錯誤示例
name = "Alice"
print("Hello, name") # 應該是 print("Hello, " + name)
# 錯誤示例
print('It's a sunny day.') # 應該是 print("It's a sunny day.")
# 錯誤示例
print("Hello\nWorld") # 應該是 print("Hello\\nWorld")
# 錯誤示例
text = "Hello, World"
print(text.uppercase()) # 應該是 print(text.upper())
# 錯誤示例
text = "Hello"
if text == True: # 應該是 if text == "True":
print("String is True")