How to do variable assignment inside a while(expression) loop in Python?

前端 未结 6 1866
离开以前
离开以前 2020-12-08 22:30

I have the variable assignment in order to return the assigned value and compare that to an empty string, directly in the while loop.

Here is how I\'m doing it in PH

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 22:51

    names = []
    for name in iter(lambda: raw_input("Name: "), ''):
        names.append(name)
    

提交回复
热议问题