How can I generate a list of 3-digit numbers for which the sum of their digits equal 17? for example: 0 98, 197, 188, etc..
One solution with list comprehension
[(a,b,c) for a in range(10) for b in range(10) for c in range(10) if a+b+c ==17]
Then just convert this to strings or whatever you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.