python创建数字列表_Python使用数字创建一组列表

假设我有一个字符串n='22'和另一个数字a=4,所以n是str,a是int。我想创建一组列表,比如:list1 = [22, 12, 2] #decreasing n by 10, the last item must be single digit, positive or 0

list2 = [22, 11, 0] #decreasing n by 11, last item must be single digit, positive or 0

list3 = [22, 21, 20] #decreasing n by 1, last item must have last digit 0

list4 = [22, 13] #decreasing n by 9, last item must be single digit. if last item is == a, remove from list

list5 = [22, 32] #increasing n by 10, last item must have first digit as a - 1

list6 = [22, 33] #increasing n by 11, last item must have first digit as a - 1

list7 = [22, 23] #increasing n by 1, last item must have last digit a - 1

list8 = [22, 31] #increasing n by 9, last item must have first digit a - 1

我正在为如何开始这件事而挣扎。也许你能告诉我如何解决这个问题?在

顺便说一下,如果一个条件不能满足,那么这个列表中只有n个。假设n='20',a=4:

^{pr2}$

这也是一个学校项目,对于一个包含列表项的列表中的索引。我想不出更好的办法来解决这个问题。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值