-3

This is vb6 code

Dim i As Long, mystr As String

For i = 0 To 9

    mystr = mystr & "\u000" & i & vbCrLf

Next

Me.Text1.Text = mystr

The output has to be:

\u0000

\u0001

\u0002

\u0003

\u0004

\u0005

\u0006

\u0007

\u0008

\u0009

JoePythonKing
  • 1,080
  • 1
  • 9
  • 18

1 Answers1

1
mystr = ''
for i in range(10):
   mystr = mystr + '\\u000' + str(i) + '\n'

print(mystr)
AiRiFiEd
  • 311
  • 2
  • 12
  • Now, if I just put python mystr to the console without print I get ''\\u0000\n\\u0001\n\\u0002\n\\u0003\n\\u0004\n\\u0005\n\\u0006\n\\u0007\n\\u0008\n\\u0009\n'". Print has changed the mystr string. The vb6 didn't have a print instruction. I would like the mystr to be "'\u0000\n\u0001\n\u0002\n\u0003\n\u0004\n\u0005\n\u0006\n\u0007\n\u0008\n\u0009\n'" – JoePythonKing Mar 04 '19 at 09:13
  • hi..are you trying to export the string to be read by another program? – AiRiFiEd Mar 04 '19 at 09:29
  • I think I am trying to get a string with a lot of unicode literals so I can iterate them and print the character that the unicode literal pertains to. – JoePythonKing Mar 04 '19 at 09:40
  • if you were to iterate through mystr from the answer, it will only have one '\' – AiRiFiEd Mar 04 '19 at 09:48