+ 2

How can I generate using "yield" the data from that list in that order

https://code.sololearn.com/c7kbZGjRBA31/?ref=app

10th Jun 2022, 3:06 AM
Alejandro47
Alejandro47 - avatar
7 ответов
+ 3
for i in c: print(next(spell(txt)))
10th Jun 2022, 3:25 AM
Solo
Solo - avatar
+ 1
Alejandro47 Fix identation error at line 8
10th Jun 2022, 3:21 AM
NonStop CODING
NonStop CODING - avatar
0
Identation it'snt enough
10th Jun 2022, 3:23 AM
Alejandro47
Alejandro47 - avatar
0
That fix it
10th Jun 2022, 3:28 AM
Alejandro47
Alejandro47 - avatar
0
But I didn't understand why because they don't teach me that function yet
10th Jun 2022, 3:28 AM
Alejandro47
Alejandro47 - avatar
0
Alejandro47 # Hi! You can take a look at this one, build on your ideas: def spell_func(txt): # Design generator. for c in txt: yield c.upper() # Use generator, eihter in this way: s = "hello" spell = spell_func(s) # Create generator. try: while True: print(spell.__next__()) except StopIteration: print("") # Or in this way: s2 = "world" spell = spell_func(s2) # Create generator. for c in spell: # Using' inbuild __next__'. print(c) # Or at this one: https://code.sololearn.com/cwpnhdc32l6s/?ref=app
10th Jun 2022, 4:27 AM
Per Bratthammar
Per Bratthammar - avatar
0
Alejandro47 , mean you haven't gone through this yet, is that your homework? There are tons of ways to solve this, I showed you the easiest way to fix your code, not solve it.
10th Jun 2022, 2:39 PM
Solo
Solo - avatar