0

I need to do an input of the string 'AEN' and it must split into ('A', 'E', 'N')

Ive tried several different splits, but it never produces what i need.

The image shows the code I have done.

What im trying is that x produces a result like y. But, Im having issues whit how to achieve it.

x=input('Letras: ')

y=input('Letras: ')

print(x.split())

print(y.split())

Letras: AEN

Letras: A E N

['AEN']

['A', 'E', 'N'] 
tadman
  • 208,517
  • 23
  • 234
  • 262
Caballu
  • 1
  • 1
  • "split" is not a programming language. Which one are you using? – tadman Nov 22 '22 at 00:27
  • I am using google colaboratory. Its what my course professor has us using. – Caballu Nov 22 '22 at 00:38
  • Please specify the **programming language** you are using. It's not hard! Without that we've got no idea what this is. Maybe it's pseudo code? – tadman Nov 22 '22 at 00:39
  • Please post code, errors, sample data or textual output here as plain-text, not as images that can be hard to read, can’t be copy-pasted to help test code or use in answers, and are barrier to those who depend on screen readers or translation tools. You can edit your question to add the code in the body of your question. For easy formatting use the `{}` button to mark blocks of code, or indent with four spaces for the same effect. The contents of a **screenshot can’t be searched, run as code, or easily copied and edited to create a solution.** – tadman Nov 22 '22 at 00:39
  • 1
    Sorry first time using this. the programming language is python – Caballu Nov 22 '22 at 00:43
  • I've retagged this as Python so it gets some attention. Keep in mind people look for specific tags they can answer, so mistagging means people may never see it. – tadman Nov 22 '22 at 02:21
  • No need to apologize, just explaining. Don't worry about it. – tadman Nov 22 '22 at 02:28
  • Does this answer your question? [How do I split a string into a list of characters?](https://stackoverflow.com/questions/4978787/how-do-i-split-a-string-into-a-list-of-characters) – Marcus.Aurelianus Nov 22 '22 at 02:30

1 Answers1

1

You just want list, which will take an arbitrary iterable and produce a new list, one item per element. A string is considered to be an iterable of individual characters.

>>> list('AEN')
['A', 'E', 'N']

str.split is for splitting a string base on a given delimiter (or arbitrary whitespace, when no delimiter is given). For example,

>>> 'AEN'.split('E')
['A', 'N']

When the given delimiter is not found in the string, it is vacuously split into a single string, identical to the original.

chepner
  • 497,756
  • 71
  • 530
  • 681