简体   繁体   English

TwilioQuest - -帮助,我的代码。 Python class 叫西铁城

[英]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.

相关问题 Python:帮助我优化此代码。 - Python: Help Me optimize this code. 我正在研究 Python Class 和方法。 但我不知道我的代码有什么问题。 需要帮忙。 P3、P4 的结果不起作用 - I am studying Python Class and method. But I don't know whats wrong with my code. Need help. Result for P3, P4 do not work 我需要帮助完成我的代码。 注意我是 Python 的初学者 - I need help completing my code. Note I am a beginner in Python 想要在我的JavaScript代码中调用python api。 我只想检查一下如何通过python调用hello world并以javascript打印 - want to call python api in my javascript code. I just want to check that how hello world is called from python and printed in javascript 我的 Python 代码有问题。 有错误,“未解决的参考” - Having a problem with my Python Code. Has the error, “unresolved reference” 无法杀死我的python代码。 怎么了? - Can't kill my python code. What's wrong? 试图缩短我的 python 代码。 有人有想法吗? - Trying to shorten my python code. Does anyone have an idea? Noobie需要帮助来调试简单的python / django代码。 为什么这种视图不起作用? - Noobie needs help debugging simple python/django code. Why won't this view work? 需要帮助来识别我的代码中的错误。 Tkinter 消息框未显示所需 output - Need help in identifying the mistake in my code. Tkinter messagebox not displaying desired output 关于改进我的代码的建议。 - Suggestions on improving my code.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM