Search code examples
pythonstringintegerchatbot

How to have integer subtract from a string in python?


I'm currently working on a chatbot from scratch as an assignment for my intro to python class. In my assignment I need to have at least one "mathematical component". I cant seem to find out how to have my input integer subtract from a string.

Attached is a screen shot, My goal is to have them input how many days a week they cook at home and have that subtract from 7 automatically.

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?')

Solution

  • You are looking for this

    day = input()
    required_days = 7 - int(day)
    print('So what do you do the other ' + str(required_days) + ' days?')