python面向对象编程类型:列表对象不是卡拉布吗

2024-04-26 21:28:37 发布

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

class y():
    def __init__(self,favourite_channels = [""]):

        self.favourite_channels= favourite_channels
    def favourite_channels(self,i):
        print("Ur Favourite Channel=",i)
        self.favourite_channels.append(i)
x = y()
print("""*******************

1. Favourite Channel
press q to the exit
*******************""")

while True:

    a = input("Select : ")
    if a=="1":
        channels=input("Your fav channels use , to the split")
        addable_channels =channels.split(",")
        for i in addable_channels:
            x.favourite_channels(i)


    elif a=="q":
        break
    else:
        print("İnvalid Number")

Tags: thetoselfinputinitdefchannelclass