Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 为什么我的代码没有脱离while循环?_Python 3.x_While Loop - Fatal编程技术网

Python 3.x 为什么我的代码没有脱离while循环?

Python 3.x 为什么我的代码没有脱离while循环?,python-3.x,while-loop,Python 3.x,While Loop,我有这个代码来显示两个幂: print ("How many powers of two would you like to see?") number=int(input()) values=[2] count=1 while count <= number: length=len(values) index=length-1 number=values[index]*2 values.append(number) count=count+1

我有这个代码来显示两个幂:

print ("How many powers of two would you like to see?")
number=int(input())
values=[2]
count=1
while count <=  number:
    length=len(values)
    index=length-1
    number=values[index]*2
    values.append(number)
    count=count+1 
print (values)
print(“您希望看到二的多少次幂?”)
number=int(输入())
值=[2]
计数=1

而count如果您查看number的值,在第40次迭代之后,
count=40
但是

number = 2199023255552
number = 21430172143725346418968500981200036211228096234110672148875007767407021022498722449863967576313917162551893458351062936503742905713846280871969155149397149607869135549648461970842149210124742283755908364306092949967163882534797535118331087892154125829142392955373084335320859663305248773674411336138752
在第1000次迭代之后,
count=1000

number = 2199023255552
number = 21430172143725346418968500981200036211228096234110672148875007767407021022498722449863967576313917162551893458351062936503742905713846280871969155149397149607869135549648461970842149210124742283755908364306092949967163882534797535118331087892154125829142392955373084335320859663305248773674411336138752

因此,计数永远不会超过
数字,循环也永远不会中断。你可以通过不改变循环中的<代码>编号<代码>的值来改变这一点。

你比较<代码>计数可能是因为你正在改变循环中的“数字”,而不仅仅是“计数”,如果它有帮助,请考虑接受答案: