How to use % in a string to actually show % in the text field?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Surtarso

I want to show a % sign inside a string… is there a way?

$AccuracyLabel.text = "Accuracy: %s" % (int(round((float(PlayerData.shots_hit) / PlayerData.shots_fired) * 100)))

prints and integer (as expected) so

Accuracy: 87

how do I get it to be Accuracy: 87% ?
I tried your example with escaping for quotes within quotes with \ but \% didnt help…

:bust_in_silhouette: Reply From: kylemcclinton

Double the percent sign: (“Accuracy: %s%%”)

thx! =) couldnt find that answer anywhere…

Surtarso | 2021-02-24 10:02