如何从列表中减去11并在同一列表中一次减去mod 121? [英] How do I subtract 11 from a list and mod 121 the same list all at once?

查看:98
本文介绍了如何从列表中减去11并在同一列表中一次减去mod 121?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是素数论的.该理论实际上显示为公理因数,例如2 ^ n-1,其中n = 11或n = 23或n = 29.当然,当这些数是梅森素数时,它不会考虑n = 7或n = 31.

This is for prime number theory. This theory which actually shows up as an axiom factors numbers like 2^n-1 where n=11 or n=23 or n=29. Of course it would not factor n=7 or n=31 when those are Mersenne prime numbers.

希望我能在这里得到帮助,我希望一次完成所有这一切.我在下面有这个清单.我想从整个列表中减去-11,然后在下一个实例mod 121中减去后的列表,同时保持枚举列表.能做到吗?

Hopefully I can get help here I wish to do this all at once. I have this list below. I want to -11 from the entire list and then in the next instance mod 121 the list right after the subtraction while maintaining the enumerated list at the same time. Can this be done?

我收到此错误:

print([x % 121 for x in lst1])
TypeError: not all arguments converted during string formatting

以下是列表和我拥有的代码的一部分:

Here is part of the list and the code I have:

lst1 = [20, '231', 21, '243', 22, '247', 23, '253', 24, '259']
([int(i)-11 if isinstance(i, str) else i for i in lst1])
print([x % 121 for x in lst1])

推荐答案

这是一个解决方案:


lst1 = [20, '231', 21, '243', 22, '247', 23, '253', 24, '259']
print([(int(item)-11)%121 for item in lst1])

这篇关于如何从列表中减去11并在同一列表中一次减去mod 121?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆