2

Here's my code, and the error message:

>>> message = ‘The price of this {0:s} laptop I {1:d} USD and the exchange rate is {2:4.2f} USD to 1 EUR’.format(‘Apple’, 1299, 1.23342342)
SyntaxError: invalid character in identifier

According to the book I'm following, my code is correct. I should mention that the word "The" is highlighted in pink and the words "and" "is" both show up yellow.

2
  • It looks like you are using the wrong quotes. Use the ' or " characters to quote your string. Commented Apr 25, 2017 at 2:40
  • Thanks, yep, you're right! Commented Apr 25, 2017 at 3:10

1 Answer 1

2

You're using the wrong quote characters, you need to use ' or ".

message = 'The price of this {0:s} laptop I {1:d} USD and the exchange rate is {2:4.2f} USD to 1 EUR'.format('Apple', 1299, 1.23342342)
Sign up to request clarification or add additional context in comments.

1 Comment

Of course, thanks. I sure wish the error message would point at the quotes.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.