-3
我想比较在我的第一个函数中检索到的两个字符串值,但它不起作用。它一直告诉我'无效的语法',并将我的光标移动到elif行。比较2个字符串值,不起作用!?
这是我的计划......
def find_number_of_service():
with open('TheData.txt', 'r') as data_file:
data = data_file.read()
countS = data.count('S')
countW = data.count('W')
print ("There are " + str(countS) + " S's")
print ("There are " + str(countW) + " W's")
return
def find_popular_service():
if (countS) > (countW):
print ("The most used service to buy tickets was the school.")
elif print ("The most used service to buy tickets was the website.")
return
#Main program
find_number_of_service()
find_popular_service()
预先感谢您。
你有太多的错误就更不用说了。你的缩进是关闭的,你使用了没有条件和冒号的elif,你没有在你的函数中定义countS和countW等等。 – Selcuk
我会建议您优化您的问题,更具特色,并只保留所需的信息 - 这样您可以更快地得到答案 – Farside