A better way to accomplish loop

J

Joseph L. Casale

I have an issue with some code I have been passed:

for (x, y) in [(a_dict1, a_tuple[0]), (a_dict2, a_tuple[1])]:


I only noticed it as PyCharm failed to assign the str type to y, whereas itknew
the tuples 0 and 1 item were type str.


In the loop it flags the passing of y into a method that expects type str. I can ignore
it, but looking at the loop, I cant help but think there is a better way?


Any guidance would be appreciated!
jlc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top