[Python] Underscore Usage
I'll post about the underscore(_) in Python. Basic Usage Previous Value If you use underscore in REPL, it points to the previous result. >>> 3 + 5 8 >>> _ 8 >>> _ + 7 15 Ignoring Value You can use underscore for ignoring values. a, _, b = (1, 2, 3) print(f"{a}, {b}") # 1, 3 a, *_, b = (1, 2, 3, 4, 5, 6, 7) print(f"{a}, {b}") # 1, 7 If you use underscore in a loop, it indicates the current value ..
2021. 4. 26.