【问题标题】:Invalid Syntax on simple if statement [closed]简单 if 语句的语法无效[关闭]
【发布时间】:2013-12-14 11:00:30
【问题描述】:
import time
print ("Hello and welcome to my text adventure!")
time.sleep(2)
Name = input ("What is your name?")
print ("Hello " + Name )
time.sleep(2)
print ("You must choose between joining the Guild or protecting the Girl.")
time.sleep(3)
G = input ("Which do you choose? Guild/Girl")
if: G = "Guild"
    print ("So you chose the Guild. Interesting.")
else print ("So you chose the Girl. How chivalrous.")
# If statements not working.

我不明白这是怎么回事,我试着移动冒号看看它是否会起作用,但无济于事......我对此很陌生,这是为了我的 A -水平计算课程,所以我需要帮助...

【问题讨论】:

  • @aga 我对此很陌生,这是为我的 A-Level 计算课程准备的 - 可能这个人是 python 新手,没有什么离题跨度>
  • 这个问题似乎离题了,因为它是关于一个不太可能帮助未来访问者的微不足道的语法错误

标签: python if-statement syntax


【解决方案1】:

应该是的

if G == "Guild":
    ...
else:
    ...

【讨论】:

    猜你喜欢
    • 2022-12-03
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2022-08-24
    • 1970-01-01
    • 2016-11-09
    • 2020-02-22
    • 1970-01-01
    相关资源
    最近更新 更多