[英]TwilioQuest - -Help, with my code. Python class called Citizen
What am I missing in my code?我的代码中缺少什么? I've tried different variations of this code, maybe five.
我已经尝试过此代码的不同变体,可能有五个。 I've run the code and I get the statement to execute, but there is still something missing.
我已经运行了代码并得到了要执行的语句,但仍然缺少一些东西。 The name doesn't print along with it.
该名称不与它一起打印。 Attached is a screenshot of the parameters that were given.
附件是给定参数的屏幕截图。
enter image description here在此处输入图像描述
enter image description here在此处输入图像描述
class Citizen:
"""
this class is to describe a citizen of the City of Python
"""
def __init__(self, first_name, last_name):
self.first_name = Rey
self.last_name = Rizo
def full_name(x):
x = self.first_name + self.last_name
def greeting(greet):
full_name = raw_input(full_name)
return greet + x
print("For the glory of Python!")
class Citizen:
"""
this class is to describe a citizen of the City of Python
"""
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
def full_name():
return self.first_name + self.last_name
def greeting(greet):
return greet + self.full_name()
When you initiate a new citizen, use:当您启动新公民时,请使用:
citizen = Citizen(“first_name”, “last_name”)
To print the name:要打印名称:
print(citizen.full_name)
To greet:打招呼:
print(citizen.greeting(“Hello”))
class Citizen:
"this class is to describe a citizen of the City of Python"
def __init__(self, first_name, last_name):
self.first_name = first_name #this is an instance variable
self.last_name = last_name
def full_name(self): #This is an instance method
return self.first_name + " " + self.last_name #This took the 2 instance variables and put them together
greeting = "For the glory of Python!"
This is what worked for me.这对我有用。
class Citizen:
"""a citizen of the City of Python"""
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
def full_name(self):
return (f'{self.first_name} {self.last_name}')
greeting = 'For the glory of Python!'
This worked for me.这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.