我的Python语法无效

时间:2018-08-31 11:39:37

标签: python python-3.x

我对这个论坛很陌生,而且是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')

2 个答案:

答案 0 :(得分:0)

您的indentations已关闭,并且在if/ else statements末尾缺少:冒号

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')

答案 1 :(得分:0)

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

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

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