如何使inpit影响函数的参数? python,在我试图制作靴子的时候对我不适

发布于 2025-02-05 17:29:16 字数 429 浏览 3 评论 0原文

def market_list(user_request):
    fixed_list_option_1 = customer_products_string.split(' ', )
    if user_request == 1:
        return fixed_list_option_1
    elif user_request == 2:
        return fixed_list_option_1.count


customer_products_string = "pizza,apple"
user_request = input("What is your request? (insert the number of the command) : ")
print(market_list(user_request))
def market_list(user_request):
    fixed_list_option_1 = customer_products_string.split(' ', )
    if user_request == 1:
        return fixed_list_option_1
    elif user_request == 2:
        return fixed_list_option_1.count


customer_products_string = "pizza,apple"
user_request = input("What is your request? (insert the number of the command) : ")
print(market_list(user_request))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉城已无爱 2025-02-12 17:29:17

输入似乎在这里字符串。这就是为什么您应该使用user_request ==“ 1”或“ 2”或int(输入(“ ...”))的原因。

def market_list(user_request):
    fixed_list_option_1 = customer_products_string.split(',', )
    if user_request == "1":
        return fixed_list_option_1
    elif user_request == "2":
        return len(fixed_list_option_1)

customer_products_string = "pizza,apple"
user_request = input("What is your request? (insert the number of the command) : ")
print(market_list(user_request))

Input seems string here. That's why you should use user_request == "1" or "2" or int(input("...")).

def market_list(user_request):
    fixed_list_option_1 = customer_products_string.split(',', )
    if user_request == "1":
        return fixed_list_option_1
    elif user_request == "2":
        return len(fixed_list_option_1)

customer_products_string = "pizza,apple"
user_request = input("What is your request? (insert the number of the command) : ")
print(market_list(user_request))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文