首页 > 解决方案 > 我在 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')

标签: pythonpython-3.x

解决方案


您的语法问题是您需要使用空格或制表符来编写正文。

if conditions :
    print("conditions are true")
else :
    print("they are not true")

如您所见,我使用空格来分隔主体。


推荐阅读