+ 1

python print format

print("I said: %r.". % x) ^ SyntaxError: invalid syntax I have a SyntaxError for this, what did I do wrong here?

24th Jun 2017, 2:17 PM
Luan Mai
Luan Mai - avatar
4 Respuestas
+ 10
print("I said {}".format("hello")) You can use this.😊😊
24th Jun 2017, 2:20 PM
Nithiwat
Nithiwat - avatar
+ 7
You can check this https://pyformat.info/
24th Jun 2017, 2:25 PM
Nithiwat
Nithiwat - avatar
+ 1
Thanks. I can use that but I want to know that did I go wrong with the first code?
24th Jun 2017, 2:22 PM
Luan Mai
Luan Mai - avatar
0
Could be the period / decimal inside the quotes unless your goal was for that to print as well {%r.".} != {%r".}
26th Jun 2017, 5:11 PM
Wes