无法让我输入重复或删除

杰里米·布拉德利(Jeremy Bradley)

好吧,所以我想做的就是让该程序询问用户退出,随机运行或擦除已绘制内容并再次随机运行的输入。

我的运行部分正常运行,我需要帮助来获得输入(称为“消息”)以实际运行选项“ w”和“ e”,到目前为止,它所做的只是绘制一个新的随机运行。(我可能只是输入了错误的turtle命令,无法弄清楚)。我相信我使用了错误的单词(if,while,elif)来使菜单正常工作。我还认为jumpto函数无法正常工作,或者正在其他函数中对其进行重置。

import turtle as t
import random as r
count=0
t.speed(0)
x=r.randint(1,100)
y=r.randint(1,100)
#----------------------------------------
""" sets the turtle to a new starting point"""
def jumpto(x,y):
    t.penup()
    t.goto(x,y)
    t.pendown()
    return None

def randomrun ():
    """runs turtle around 1000 steps randomly"""

    count=0
    while count <1000:
        count+=1
        t. forward (6)
        t.left(r.randint(0,360))#360 degree choice of rotation
    t.dot(10)#puts a dot at the end of the run of lines
    count=0#resets count so it can do it again
    x=r.randint(1,100)
    y=r.randint(1,100)
    message= input("q to quit \nw to walk randomly for 1000 steps \ne to erase screen and walk randomly ")
    return message
#-------------------------------------------
message= input("q to quit \nw to walk randomly for 1000 steps \ne to erase screen and walk randomly ")

if message =="w": 
   randomrun()
   jumpto(x,y)

if message == "q":
    print(" have a nice day")

if message== "e":
    t.clear()
    randomrun()
    jumpto(x,y)
特里·扬·里迪(Terry Jan Reedy)

returnrandomrun被忽略。无论如何,重复输入提示是一个坏主意。删除它,然后将其return从中删除randomrun并以input循环结尾

while True:
    message = input("q to quit\n"  # use implicit string joining
                    "w to walk randomly for 1000 steps\n"
                    "e to erase screen and walk randomly\n"
                    "> ")[:1].lower()  # forgive non-exact input
    if message == "q":
        print("Have a nice day!")
        break
    elif message =="w": 
        randomrun()
        jumpto(x,y)
    elif message == "e":
        t.clear()
        randomrun()
        jumpto(x,y)
    else:
        print("Input not recognized; try again.")

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

我似乎无法防止姓名重复输入

来自分类Dev

从输入中删除重复的空格

来自分类Dev

我无法创建数组,并且我的删除重复项也有问题

来自分类Dev

无法正确删除重复项

来自分类Dev

无法正确删除重复项

来自分类Dev

预先输入/猎犬:从本地删除重复项

来自分类Dev

如何删除链表输入中的重复条目?

来自分类Dev

我无法删除折线

来自分类Dev

我无法删除whistespace

来自分类Dev

JTextField Keylistener无法删除输入

来自分类Dev

JTextField Keylistener无法删除输入

来自分类Dev

我无法删除我的VPC

来自分类Dev

我无法删除我的状态

来自分类Dev

我无法使用reactjs输入输入文本

来自分类Dev

我无法输入Go键

来自分类Dev

我突然无法输入等号(=)

来自分类Dev

PySpark DataFrame无法删除重复项

来自分类Dev

sort -u无法删除重复的行

来自分类Dev

熊猫:重复的列,无法删除它们

来自分类Dev

array_merge 删除我的重复项

来自分类Dev

无法删除文件-rm:无法删除输入/输出错误

来自分类Dev

无法删除文件-rm:无法删除输入/输出错误

来自分类Dev

我试图细分列表,然后根据给定的输入值删除重复项?但是我错过了一些东西

来自分类Dev

我无法删除整列-熊猫

来自分类Dev

我无法删除整列-熊猫

来自分类Dev

我无法从SQLiteDatabase删除行

来自分类Dev

我无法删除genymotion。没用

来自分类Dev

我无法删除根终端

来自分类Dev

我无法删除 NullPointerException 错误