def file(char, filename):
for currentFile in filename:
print(currentFile.strip())
def string(char, str):
count = 0
if char in 'abcdefghijklmnopqrstuvwxyz':
count += 1
string(char,str)
else:
print("Incorrect Letters")
print(count)
def main():
char = input("Enter character: ")
openFile = input("Enter the filename: ")
filename = open(openFile)
file(char, filename)
string(char, str)
main()
我正在尝试计算某些字符,例如,如果我要在字符输入提示中输入“W”,它应该只计算 W。我该怎么做?我正在尝试在 def 字符串函数中进行递归
谢谢你。