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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top