by MapleWalnut · 4y ago · 0 comments
def main() -> None:
words = ["Hello", "World"]
for word in words:
print(word)
if __name__ == '__main__':
main() def main() -> None:
words = []
for word in (words + ["Hello"]):
print(word)
if __name__ == '__main__':
main()
MyPy rejects to infer the type of the iterable. Here's an equivalent Haskell version that does infer the type without manual annotations: import Data.Foldable (for_)
main = do
let words = []
for_ (words ++ ["Hello"]) (\word -> print word) function main() {
let words = [];
for (const word of [...words, 'Hello']) {
console.log(word);
}
}