Python If statement equal string -
i want jobber()
following: if user inputs "talk" runs chat()
, "calc" calculator()
.
this first project , new help.
import sys import time def chat(): print('hello there. name?') name = sys.stdin.readline() print('your name %s...interesting. name chat created have small planned out conversation when call me :)' % (name)) time.sleep(2) print('how weather in town today?') weather = sys.stdin.readline() time.sleep(1.5) print('your weather %s? weather in town quite sunny.' % (weather)) time.sleep(2) print('this conversation can make @ moment. please patient while creator trys update me.') def calculator(): print('how money have?') money = int(sys.stdin.readline()) print('how paid?') job = int(sys.stdin.readline()) print('how spend?') spent = int(sys.stdin.readline()) week in range(0,30): money = money + job - spent print('week %s. money %s' % (week,money)) def jobber(): print('type talk short chat. type calc money calculator.') choice = int(sys.stdin.readline()) if choice == 1: chat() if choice == 2: calculator()
use input()
, convert lowercase
def jobber(): choice = input('type talk short chat. type calc money calculator.').lower() if choice == "talk": chat() if choice == "calc": calculator()
Comments
Post a Comment