Type Error: "'types.genericalias' Object Is Not Iterable"
I am working on a project is to convert text into numbers. (For example, 'hello world' would be converted to '8 5 12 12 15 27 23 15 18 12 4'). In line 10 of my code, the for loop c
Solution 1:
You need to use list
with ()
, not []
.
plaintext = list(input("Enter plaintext:.....")) # With ()
In newer versions of Python, container types such as list
can be hinted directly to specify the type of the elements the container holds. By using square braces here, you create a generic type hint of a list (a "generic alias"). A generic alias for a list is not iterable, as it is not actually a list. This is what causes your error.
Post a Comment for "Type Error: "'types.genericalias' Object Is Not Iterable""