metasyntactic-variable

What is the purpose of the single underscore "_" variable in Python?

What is the purpose of the single underscore "_" variable in Python? Question: What is the meaning of _ after for in this code? if tbh.bag: n = 0 for _ in tbh.bag.atom_set(): n += 1 Asked By: alwbtc || Source Answers: It’s just a variable name, and it’s conventional in python to use _ …

Total answers: 5

Underscore _ as variable name in Python

Underscore _ as variable name in Python Question: Peter Norvig has an essay describing a program to solve sudoku puzzles, even the hardest ones, by combining deterministic logical operations and smart traversal of the possible solutions. The latter is done recursively; here’s that function (source): def search(values): “Using depth-first search and propagation, try all possible …

Total answers: 3