How to use multiple yield statement in Python

1 Answer

0 votes
def multiple_yield():  
    str1 = "str1 String"  
    yield str1  
      
    str2 = "str2 string"  
    yield str2  
      
    str3 = "str2 String"  
    yield str3  

obj = multiple_yield()  

print(next(obj))  
print(next(obj))  
print(next(obj))  



'''
run:

str1 String
str2 string
str2 String

'''

 



answered Dec 2, 2022 by avibootz

Related questions

1 answer 184 views
1 answer 169 views
3 answers 244 views
244 views asked Jun 18, 2020 by avibootz
1 answer 233 views
...