在Python中出现的无明显原因的语法错误。

huangapple go评论62阅读模式
英文:

Syntax error for no apparent reason in python

问题

I have no idea why I have a syntax error in python at all. Here is my code. I am a beginner. This is Python 3.8.1 shell:

name = str(input("What is your name?"))
age = int(input("How old are you?"))  # <-- error here
siblings = int(input("How many siblings do you have?"))
print("Your name is", name)
print("You are", age., "years old")
print("And you have", siblings, "siblings")

This is very weird. I don't understand why it is happening. Look at the letter "a" in age.

英文:

I have no idea why i have a syntax error in python at all here is my code I am a beginner this is python 3.8.1 shell:

name = str(input(&quot;What is your name?&quot;))
age = int(input(&quot;How old are you?&quot;)) # &lt;-- error here
siblings = int(input(&quot;How many siblings do you have?&quot;)) 
print(&quot;Your name is&quot;, name)    
print(&quot;You are&quot;, age., &quot;years old&quot;) 
print(&quot;And you have&quot;, siblings, &quot;siblings&quot;)

This very weird. I don't understand why it is happening look at the letter a in age.

答案1

得分: 1

这只是 age 而不是 age.

name = str(input("你叫什么名字?"))
age = int(input("你多大了?")) # 在这一行找不到错误
siblings = int(input("你有多少兄弟姐妹?")) 
print("你的名字是", name)    
print("你今年", age, "岁了")  # 我修改了这一行
print("你有", siblings, "个兄弟姐妹")
英文:

It is just age not age.

name = str(input(&quot;What is your name?&quot;))
age = int(input(&quot;How old are you?&quot;)) # didn&#39;t find the error on this line
siblings = int(input(&quot;How many siblings do you have?&quot;)) 
print(&quot;Your name is&quot;, name)    
print(&quot;You are&quot;, age, &quot;years old&quot;)  # I changed this line
print(&quot;And you have&quot;, siblings, &quot;siblings&quot;)

huangapple
  • 本文由 发表于 2020年1月7日 02:05:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616864.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定