Python中文
首页
教程
问答
标签
搜索
登录
注册
冒号语法无效
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在写一个程序,包括速度限制之类的while和if语句。我试着让它在输出结果后,它问我是否想用while循环重做程序</p> <p>我听说如果我有一个太多的括号或一个开放的括号会发生这种情况。我所有的支架都很好</p> <pre class="lang-py prettyprint-override"><code>ques1 = int(input('What speed is the car travelling? ')) check = ques1 running = True while running == True: if 0 <= check <= 50: print('You are clear.') if 51 <= check <= 60: print('10 demerit points') if 61 <= check <= 70: print('20 demerit points') if 71 <= check <= 80: print('30 demerit points') if 81 <= check <= 90: print('50 demerit points') if 91 <= check <= 1000: print("100 demerit points") dasques = input('Do you want to try again? y/n '): if dasques == ('n'): running = False </code></pre> <p><strong>预期输出:</strong></p> <pre><code>Hoping to get : 50 demerit points Do you want to try again? y/n </code></pre> <p>但我现在</p> <blockquote> <p>"invalid syntax" with the colon behind: [ dasques = input('Do you want to try again? y/n '):]</p> </blockquote> <p>以红色突出显示</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>请更改以下代码行</p> <pre><code>dasques = input('Do you want to try again? y/n ') if dasques == ('n'): running = False </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在python中从数据帧列中删除分类值?
2 回答
如何在python中从数据帧列表中删除引号
4 回答
如何在python中从数据帧创建列表
1 回答
如何在Python中从数据帧创建嵌套的JSON
3 回答
如何在Python中从数据帧显示wordcloud
9 回答
如何在Python中从数据帧的时间戳中删除字符
10 回答
如何在Python中从数据帧绘制简单绘图?
6 回答
如何在python中从数据帧行提取具有特定长度的范围?
7 回答
如何在python中从数据帧设置dict中的值
3 回答
如何在Python中从数据库中获得一个结果
2 回答
如何在python中从数据框中绘制分类条形图
4 回答
如何在Python中从数据框中选择特定细节?
9 回答
如何在python中从数据集中删除unicode
4 回答
如何在python中从数据集中删除某些数值?
6 回答
如何在python中从数据集中选择行
10 回答
如何在Python中从数组中删除元素
1 回答
如何在python中从数组中删除单个倒逗号?
8 回答
如何在python中从数组中删除对象?
9 回答
如何在python中从数组中删除引号
2 回答
如何在python中从数组中删除所有最小值
5 回答