This question has already been answered:

There is a line, for example, "ΠΌΠ°ΠΉ" should be made so that a list of approximately the following form is obtained: ['ΠΌ', 'Π°', 'ΠΉ'] .

split does not work here (at least, it did not work for me), since there is no symbol through which the word can be divided into letters.

Reported as a duplicate by jfs python Jan 21 '18 at 1:07 pm

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • What is the problem? Maybe it’s not necessary to convert it to the list) - Alex Belyaev
  • just right ... I am writing a program to decrypt the Caesar cipher. There, the entered words need to be stuffed into the sheet, as it seems to me :) - BabyPyth

3 answers 3

A string (for example, "ΠΌΠ°ΠΉ" ) is an immutable sequence of Unicode characters (Unicode code points) in Python 3. Therefore, it is enough just to pass a string to list() to get a list of characters (a variable sequence).

Some letters can consist of several characters, for example, a letter can be represented as U + 0435 U + 0308 sequences of characters in the NFD form ( Unicode normalization forms ):

 >>> print(u'\u0435\u0308') С̈ 

If you want to find letters, not symbols, you can use the \X regular expression for letters ( eXtended grapheme clusters ):

 >>> list(u'\u0435\u0308\u0436') ['С', '̈', 'Т'] >>> import regex # $ pip install regex >>> regex.findall(r'\X', u'\u0435\u0308\u0436', regex.U) ['С̈', 'Т'] 

In this case, the line contains three characters, but only two letters.

In general, not all visible characters can be represented as a single Unicode codepoint, that is, NFD is not the only reason that some characters on the screen can be represented as several Unicode codepoints ( see examples in the link above ).

    Something like this:

     print(list("abcd")) 

    If you need to go through all the characters, then

     for c in "abcd": ... 
    • one
      But why? "abcd" [0] = 'a'. - 0andriy

    If in a simple way, without regex, you can simply and explicitly:

     char_list = [] # объявляСм пустой список string = 'ΠΌΠ°ΠΉ' for c in string: # ΠΈΠ΄Π΅ΠΌ ΠΏΠΎ строкС char_list.append(c) # добавляСм Π±ΡƒΠΊΠ²Ρ‹ Π² список print(char_list) # >>>> ['ΠΌ', 'Π°', 'ΠΉ'] 
    • 2
      Simple and explicit - this is list(s) . Your option is longer and slower, because the process will not go in the built-in Python function (originally written in C, and compiled, therefore fast), but in the interpreted code. - insolor