0

Is there a way to convert the code below to have a dot added between the numbers it puts out? I'm not trying to use an algorithm or foreign library. I'm trying to continue my python knowledge with the built-in modules first

print(list("".encode("utf-8"))) 
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
  • to make your question easier to understand, please edit your question with the output you get, and the output you would like to get. – Chris Maes Jun 11 '19 at 03:05

1 Answers1

0

When I run your code it prints

>>> list("".encode("utf-8"))
[240, 159, 152, 128]

First we want to convert integers to strings; you can do this using map. map returns a map object, so I cast it to list to make the output readable:

>>> list(map(str, "".encode("utf-8")))
['240', '159', '152', '128']

Now you could use join to join all elements together with a dot:

>>> '.'.join(map(str, "".encode("utf-8")))
'240.159.152.128'
Chris Maes
  • 35,025
  • 12
  • 111
  • 136