我的Python语法无效

2024-09-27 23:21:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我是新来这个论坛的东西和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')

Tags: toyoutrueforreadinputagetime
2条回答

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

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

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

如你所见,我用空格来分隔身体。你知道吗

相关问题 更多 >

    热门问题