New course! Every coder should learn Generative AI!
Try a free lesson+ 3
Why is the output of the following python code is abc?
it=iter('abcdef') for i in range(3,6): print(next(it), end=' ')
1 Answer
+ 5
I don't know but I guess that probably iter('abcdef') creates an iterator with which you can iterate throw the String 'abcdef' using the function "next()".
the Iterator would return the char at the position it's at.
since the for-loop is executed 3 times the fist 3 characters of the oterator get printed
just guessing...
hope that helped!
happy coding! 😄