我是python(来自C++世界)的新手,正在尝试使用类方法。我创建了一个没有任何参数的方法(在这种情况下有目的地避免了self参数)。然后我试图把它 class car:
def car_method():
print("Inside Car method")
obj = car_method()
obj.car_method() <---- this creat
def duplicate_count(s):
return len([c for c in set(s.lower()) if s.lower().count(c)>1])
我很难理解这段代码的工作原理。我正在做一个codewars挑战,以返回字符串中重复元素的数量。 例如。 Asasd - > 2 我想出了我自己的暗示,但我无法真正理解这段代码的作用。如果有人可以指出我的方向,它
program1.py: a = "this is a test"
for x in a:
print(x)
program2.py: a = """this is a test
with more than one line
three, to be exact"""
for x in a:
print(x)
program3.py: im