[英]Invalid syntax: beginner at Python, my first code
我在輸入 myName 的開頭收到無效的語法消息。 我不知道為什么,也許是設置問題,但它突出顯示 myName 的第一個字母無效。
有誰知道為什么會這樣?
# This program says hello and asks for my name
print('Hello World')
print('What is your name?' # ask for their name
myName = input()
print('It is good to meet you,' + myName)
print('The length of your name is:')
print(len(myName))
print('What is your age?') # ask for their age
myAge = input()
print('You will be ' + str(int(pyAge) + 1) + ' in a year.')
問題是您忘記了行中的右括號:
print('What is your name?' # ask for their name
它應該是:
print('What is your name?') # ask for their name
另外,我對最后一行有一個快速提示。 如果您這樣做,將產生相同的輸出:
print('You will be', int(myAge) + 1, 'in a year.')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.