-1

I have a number string and a Persian string that I want to concatenate in python (my IDE is Pycharm) and when I do this, right-to-left breaks down.

num = "1200"
body = "ریال"
total = num + " " + body
print(total)

it results:

1200 ریال

but I expect this:

‏1200 ریال

what can I do?

Kasra Najafi
  • 560
  • 5
  • 11

2 Answers2

0

There is a special standard character named Right-to-left mark. you can use it with this expression:

u"\u200F"

So you can correct your code this way:

corrected = u"\u200F" + num + " " + body
print(corrected)

that results:

‏1200 ریال

Kasra Najafi
  • 560
  • 5
  • 11
0

the string isn't right to left, you're just adding the number first. try:

total = body + " " + num