【发布时间】:2023-03-06 16:28:02
【问题描述】:
我目前正在从头开始开发一个聊天机器人,作为我对 Python 课程的介绍的作业。在我的作业中,我需要至少有一个“数学成分”。我似乎不知道如何让我的输入整数从字符串中减去。
附件是一个屏幕截图,我的目标是让他们输入他们每周在家做饭的天数并自动从 7 中减去。
print('Hello! What is your name? ')
my_name = input ()
print('Nice to meet you ' + my_name)
print('So, ' + my_name + ' What is your favorite veggie?')
favorite_veggie = input ()
print('Thats nuts! ' +favorite_veggie + ' is mine too!')
print('How many days a week do you have cook at home? ')
day = input ()
print('So what do you do the other ' + ????? 'days?')
【问题讨论】:
-
执行
input('Hello! What is your name? ')、input('So, ' + my_name + ' What is your favorite veggie?')和input('How many days a week do you have cook at home? ')以获得更好的代码
标签: python string integer chatbot