I have the following code:
n = int(input()) a, b, c = map(int, input().split()) result = sum(s // c + 1 for i in range(n) for j in range(n - a * i) if (s := n - a * i - b * j - 1) >= 0) print(result)
But I have an error that Python 3.7 does not support assignment expressions in this part (s := n - a * i - b * j - 1). How can I rewrite it? I want to rewrite it to python3.7
The simple, though repetitive, fix is to "inline" the value of s.
s
result = sum((n - a * i - b * j - 1) // c + 1 for i in range(n) for j in range(n - a * i) if n - a * i - b * j - 1 >= 0)
1.4m articles
1.4m replys
5 comments
56.9k users