我得到一个无限while循环蟒蛇这里的代码为我掷骰子 它使掷骰子一遍又一遍 代码:无限循环,当在Python
#!usr/bin/python
# -*- coding: utf-8 -*-
import random
import time
import sys
print ("")
print ("This is a dice rolling simulator ")
x=raw_input("press Enter to launch the dice ")
def dice():
print("\nRolling the dice...\n")
time.sleep(1)
n=random.randint(1, 6)
if n == 1:
print '''
1
'''
if n == 2:
print '''
'''
if n == 3:
print '''
3
'''
if n == 4:
print '''
4
'''
if n == 5:
print '''
5
'''
if n == 6:
print '''
6
'''
dice()
x=raw_input("press Enter to restart the or type q to quit")
while x!= ("q"):
dice()
if x== ("q"):
print ("see you later ")
你应该把代码直接放在问题上,而不是通过一个链接到外部资源 –
看来你修改了你的循环之外的x检查x值。 – Baart
@AnandSKumar @AnandSKumar我是一个初学者,并且在输入代码时出现错误我会尝试 –