When I write the following code:
def demorgan(prop_sent, conditionals, candd):
global sn
d = 0
while d < len(conditionals) -1:
str1 = conditionals[d][4]
if str1.find("~(") > -1:
anc1 = conditionals[d][2]
The IDE says that d is an unresolved reference. When I change the while loop to a for loop, which I can't do by the way, since the length of the conditionals list will change while looping, the error message goes away.
def demorgan(prop_sent, conditionals, candd):
global sn
for d in range(len(conditionals)):
str1 = conditionals[d][4]
if str1.find("~(") > -1:
anc1 = conditionals[d][2]
I can't figure out why d is an unresolved reference in the while loop. The bug also goes away when I simply put in:
while d < 10:
Actually, on second thought this is not an error. My IDE editor (Pycharm) underlines the d variable and has a red flag in the right hand side, but when I actually step over the line, Python continues to work. This is the only time I've seen when a red flag has gone up and Python has continued to work, so I guess the problem is with the IDE.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.