0

I need help with python

I have no idea why this code doesn't work. Please explain and fix the error. https://code.sololearn.com/cJtmArnF8rW6/?ref=app

7th Mar 2019, 12:30 PM
Brayden Parker
Brayden Parker - avatar
3 Answers
+ 5
There's no error. It's just that for loop results in a generator object. You must do something with each object in the generator. Like, either print each item using: for i in input(): print(i) Or in your code, print([i for i in input()])
7th Mar 2019, 12:43 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 4
Change the code to this so you can understand what happened actually print(list(i for i in input())) Explanation... First the code will try to return a generator object of characters of string input. Then it will print the generator object. If you wrapped it with list function then you can see the elements stored on the generator
7th Mar 2019, 12:35 PM
Seniru
Seniru - avatar
+ 1
Thanks, I figured out how to make it say the text that you enter. That helped a lot!
7th Mar 2019, 12:40 PM
Brayden Parker
Brayden Parker - avatar