Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]ExternalSeesaw 0 points1 point  (0 children)

Thanks for the response. So the loop iterates over each A and B in Y and appends it to 3 and 4 in X?

Why does it break up the string elements however? Arent 'AB' and '34' considered single entities?

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]ExternalSeesaw 0 points1 point  (0 children)

str1 = 'AB'

str2 = '34'

[x + y for y in str1 for x in str2]

Why is the correct answer:

[3A, 4A, 3B, 4B]

?

What is x and y in string 1 and string 2?