Python Assign value to variable during condition in while Loop [duplicate]
2020 answer: Since Python 3.8, the “walrus operator” := exists that does exactly what you want: while data := fgetcsv(fh, 1000, “,”) != False: pass (if that fgetcsv function existed) 2013 answer: You can’t do that in Python, no assignment in expressions. At least that means you won’t accidentally type == instead of = or … Read more