python - 我在 Python 中有无效的语法
问题描述
我是这个论坛thingy和python的新手。请温柔一点。
我已经尝试修复它,但它仍然无法正常工作。我真的很紧张。帮助。
print('Print')
input('make space by pressing space')
print('Thanks for the space, space, space, spaceeeeeeee.')
input('read this? (press to continue)')
print('also thanks for your time')
print('What is your age')
age = input()
#age
print('In 42 years you will be:' + str(int(age) + 42) + ' years old')
print('Also, did you read "Hitchhikers guide to the galaxy"?')
print('Anwser with "true" or "false"')
hgttg = input()
#if's are coming
if hgttg == 'true'
print('Ah, you earned my respect')
input('good (press to continue)')
else
print('Ok, you can read it another day, you are still conversing with
me')
input('this time no respect (press to continue)')
#water adventure
print('Can you bring me a glass of water, please?')
print('Again, anwser with either "true" or "false"')
boolwater = input()
if boolwater == 'true'
print('Thanks!')
input('press to continue')
else
print('I will go get it myself ')
input('youve angered me (press to continue)')
print('Thanks for talking to me, and see you another time!')
input('Press to exit')
解决方案
您的语法问题是您需要使用空格或制表符来编写正文。
if conditions :
print("conditions are true")
else :
print("they are not true")
如您所见,我使用空格来分隔主体。
推荐阅读
- ansible - Ansible Jinja2 总是显示“已更改”
- makefile - 在 make 文件中忽略 c11 标志
- java - 覆盖应用于 RestTemplate 的 RestTemplateCustomizer
- python - 我不知道为什么我不断收到错误 'str' has not attribute 'message'
- javascript - 如何通过电子邮件发送购物车的结果?
- javascript - button.value 返回 "" 。预期 - 文本值
- bash - 向 shell 脚本中的选项提供参数列表的方法?
- angular - 如何更改 Angular 10 库构建结构
- javascript - Typescript 中的条件 super() 语句
- javascript - 如何在反应中呈现 HTMLCollection(作为道具传递)