NameError: name 'mNewCal' is not defined issue - python

Im having some issue with my code. Im not really sure what's wrong with it. Thank you
if mNewCal or fNewCal < 1200:
NameError: name 'mNewCal' is not defined
sorry if the format is a little weird, stack overflow made it weird.
gender = int(input("enter your gender as a number from the following \n Male: 1 \n Female: 2 \n " ))
height = int(input("Please enter your height in inches: "))
age = int(input("Please enter your age: "))
weight = int(input("Enter your weight in lbs: "))
exercise = int(input("How much exercise do you do during the week (enter number) \n little to no: 1 \n light: 2 \n moderate: 3 \n heavy: 4 \n "))
if gender == 1:
mBMR = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age)
elif gender == 2:
fBMR = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age)
if gender == 1:
if exercise == 1:
cal = mBMR * 1.2
elif exercise == 2:
cal = mBMR * 1.375
elif exercise == 3:
cal = mBMR * 1.55
elif exercise == 4:
cal = mBMR * 1.8
else:
if exercise == 1:
cal = fBMR * 1.2
elif exercise == 2:
cal = fBMR * 1.375
elif exercise == 3:
cal = fBMR * 1.55
elif exercise == 4:
cal = fBMR * 1.8
if gender == 1:
mTotalCal = mBMR * 1.2
#print(mTotalCal)
else:
fTotalCal = fBMR * 1.2
# print(fTotalCal)
looseWeight = str(input("do you want to loose weight? if yes, enter Y: \n if no enter N: \n "))
if looseWeight == "Y":
yesWeight = int(input("How much weight do you want to loose (lbs) ? "))
else:
print("thank you for using Nakul Industries health program!")
weeks = yesWeight
days = weeks * 7
months = days / 30
if gender == 1:
mNewCal = mTotalCal - 500
else:
fNewCal = fTotalCal - 500
if mNewCal or fNewCal < 1200:
print("WARNING! your total intake will be less then 1200 calories, please consult a doctor before following this.")
print("In order to lose " + yesWeight + " ,it will take " + weeks + " weeks " + "\n" + "or " + days + " days" + "\n or " + "approximately " + months + " months.")
else:
print(
"In order to lose " + yesWeight + " ,it will take " + weeks + " weeks " + "\n" + "or " + days + " days" + "\n or " + "approximately " + months + " months.")

You only define fNewCal or mNewCal and have both in an or statement, if you haven't defined one of the variables and it's checked by the if statement it will raise a NameError like this. You should just use one variable, like newCal, and determine whether it's female or male using the existing gender variable like this:
gender = int(input("enter your gender as a number from the following \n Male: 1 \n Female: 2 \n "))
height = int(input("Please enter your height in inches: "))
age = int(input("Please enter your age: "))
weight = int(input("Enter your weight in lbs: "))
exercise = int(input(
"How much exercise do you do during the week (enter number) \n little to no: 1 \n light: 2 \n moderate: 3 \n heavy: 4 \n "))
if gender == 1:
mBMR = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age)
elif gender == 2:
fBMR = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age)
if gender == 1:
if exercise == 1:
cal = mBMR * 1.2
elif exercise == 2:
cal = mBMR * 1.375
elif exercise == 3:
cal = mBMR * 1.55
elif exercise == 4:
cal = mBMR * 1.8
else:
if exercise == 1:
cal = fBMR * 1.2
elif exercise == 2:
cal = fBMR * 1.375
elif exercise == 3:
cal = fBMR * 1.55
elif exercise == 4:
cal = fBMR * 1.8
if gender == 1:
mTotalCal = mBMR * 1.2
# print(mTotalCal)
else:
fTotalCal = fBMR * 1.2
# print(fTotalCal)
looseWeight = str(input("do you want to loose weight? if yes, enter Y: \n if no enter N: \n "))
if looseWeight == "Y":
yesWeight = int(input("How much weight do you want to loose (lbs) ? "))
else:
print("thank you for using Nakul Industries health program!")
weeks = yesWeight
days = weeks * 7
months = days / 30
if gender == 1:
newCal = mTotalCal - 500
else:
newCal = fTotalCal - 500
if newCal < 1200:
print("WARNING! your total intake will be less then 1200 calories, please consult a doctor before following this.")
print(
"In order to lose " + yesWeight + " ,it will take " + weeks + " weeks " + "\n" + "or " + days + " days" + "\n or " + "approximately " + months + " months.")
else:
print(
"In order to lose " + yesWeight + " ,it will take " + weeks + " weeks " + "\n" + "or " + days + " days" + "\n or " + "approximately " + months + " months.")
In general, since you already have a gender variable, there's no reason to sex your other variables, either, though the remaining ones currently won't break the program because they are all contingent on gender. Here it is without the pointlessly sexed variables, it will work fine this way:
gender = int(input("enter your gender as a number from the following \n Male: 1 \n Female: 2 \n "))
height = int(input("Please enter your height in inches: "))
age = int(input("Please enter your age: "))
weight = int(input("Enter your weight in lbs: "))
exercise = int(input(
"How much exercise do you do during the week (enter number) \n little to no: 1 \n light: 2 \n moderate: 3 \n heavy: 4 \n "))
if gender == 1:
BMR = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age)
elif gender == 2:
BMR = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age)
if gender == 1:
if exercise == 1:
cal = BMR * 1.2
elif exercise == 2:
cal = BMR * 1.375
elif exercise == 3:
cal = BMR * 1.55
elif exercise == 4:
cal = BMR * 1.8
else:
if exercise == 1:
cal = BMR * 1.2
elif exercise == 2:
cal = BMR * 1.375
elif exercise == 3:
cal = BMR * 1.55
elif exercise == 4:
cal = BMR * 1.8
if gender == 1:
TotalCal = BMR * 1.2
# print(mTotalCal)
else:
TotalCal = BMR * 1.2
# print(fTotalCal)
loseWeight = str(input("do you want to loose weight? if yes, enter Y: \n if no enter N: \n "))
if loseWeight == "Y":
yesWeight = int(input("How much weight do you want to loose (lbs) ? "))
else:
print("thank you for using Nakul Industries health program!")
weeks = yesWeight
days = weeks * 7
months = days / 30
if gender == 1:
newCal = TotalCal - 500
else:
newCal = TotalCal - 500
if newCal < 1200:
print("WARNING! your total intake will be less then 1200 calories, please consult a doctor before following this.")
print(
"In order to lose " + yesWeight + " ,it will take " + weeks + " weeks " + "\n" + "or " + days + " days" + "\n or " + "approximately " + months + " months.")
else:
print(
"In order to lose " + yesWeight + " ,it will take " + weeks + " weeks " + "\n" + "or " + days + " days" + "\n or " + "approximately " + months + " months.")

Related

conditional statements causes syntax errors in python codes [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 months ago.
Improve this question
import traceback
def calculator():
# Get dog age
age = input("Input dog years: ")
try:
# Cast to float
dage = float(age)
if dage > 0:
if dage <= 1:
print ("The given dog age " + str(dage) + " is " + str(round(dage * 15) ) + " in human years")
elif 1 < dage <= 2:
print ("The given dog age " + str(dage) + " is " + str(round(dage * 12) ) + " in human years")
elif 2 < dage <= 3 :
print ("The given dog age " + str(dage) + " is " + str(round(dage * 9.3) ) + " in human years")
elif 3 < dage <= 4 :
print ("The given dog age " + str(dage) + " is " + str(round(dage * 8) ) + " in human years")
elif 4 < dage <= 5 :
print ("The given dog age " + str(dage) + " is " + str(round(dage * 7.2) ) + " in human years")
elif 5 < dage :
print ("The given dog age " + str(dage) + " is " + str(36 + 7 * (round(dage - 5.0)) + " in human years")
else:
print ("your input should be a positive number")
except:
print(age, "is an invalid age.")
print(traceback.format_exc())
calculator() # This line calls the calculator function
this code calculates the age of a dog in human years
but when it was executed, there was an error in the 24th line (else:)
There is a missing parenthesis in
elif 5 < dage :
print("The given dog age " + str(dage) + " is " + str(36 + 7 * (round(dage - 5.0)) + " in human years")
Add one more parenthesis at the end of print statement
Solution to your issue: Your code is missing a closing bracket for str() function in the print statement for your last elif. Here is the correct statement:
elif 5 < dage :
print ("The given dog age " + str(dage) + " is " + str(36 + 7 * (round(dage - 5.0))) + " in human years")
Improvements: You can also use f-strings to improve readability. See this tutorial for more details. Also, you can simplify the conditions in your elif statements as the lower bound is not needed.
Here is the code using f-strings and with some improvements:
def calculator():
age = input('Input dog years: ')
try:
dage = float(age)
if dage > 0:
msg = f'The given dog age {dage} is '
if dage <= 1:
msg += f'{dage * 15:.2f}'
elif dage <= 2:
msg += f'{dage * 12:.2f}'
elif dage <= 3 :
msg += f'{dage * 9.3:.2f}'
elif dage <= 4:
msg += f'{dage * 8:.2f}'
elif dage <= 5 :
msg += f'{dage * 7.2:.2f}'
else:
msg += f'{36 + 7 * (dage - 5.0):.2f}'
msg += ' in human years'
print(msg)
else:
print('your input should be a positive number')
except:
print(f'{age} is an invalid age.')
calculator()
You were missing a bracket on the last print in the else clause.
This is the correct code:
import traceback
def calculator():
# Get dog age
age = input("Input dog years: ")
try:
# Cast to float
dage = float(age)
if dage > 0:
if dage <= 1:
print ("The given dog age " + str(dage) + " is " + str(round(dage * 15) ) + " in human years")
elif 1 < dage <= 2:
print ("The given dog age " + str(dage) + " is " + str(round(dage * 12) ) + " in human years")
elif 2 < dage <= 3 :
print ("The given dog age " + str(dage) + " is " + str(round(dage * 9.3) ) + " in human years")
elif 3 < dage <= 4 :
print ("The given dog age " + str(dage) + " is " + str(round(dage * 8) ) + " in human years")
elif 4 < dage <= 5 :
print ("The given dog age " + str(dage) + " is " + str(round(dage * 7.2) ) + " in human years")
elif 5 < dage :
print ("The given dog age " + str(dage) + " is " + str(36 + 7 * (round(dage - 5.0)) + " in human years"))
else:
print ("your input should be a positive number")
except:
print(age, "is an invalid age.")
print(traceback.format_exc())
calculator() # This line calls the calculator function

trying to write a food ordering sys for homework in python

im learning python and for my homework i wanna make a food ordering program and get the receipt of the products purchased with the prices for the total. im struggling to get the billing process as i cannot get all the products chosen by the user displayed on the receipt
import datetime
x = datetime.datetime.now()
name = input("Enter your name: ")
address = input("Enter your address: ")
contact = input("Enter your phone number: ")
print("Hello " + name)
print("*"*31 + "Welcome, these are the items on on the menu."+"*" * 32 )
print("Menu:\n"
"1.Burger:150.\n"
"2.Fried Momo:120.\n"
"3.coffee:60.\n"
"4.Pizza:180.\n"
"5.Fried Rice:150.\n"
"6.French Fries:90.\n"
"7.Steamed Dumplings:150.\n"
"8.Chicken drumsticks:120.\n"
"9.Chicken Pakoras:120.\n"
"10.American Chop Suey:200.\n")
prices = {"1.Burger":150,
"2.Fried Momo":120,
"3.coffee":60,
"4.Pizza":180,
"5.Fried Rice":150,
"6.French Fries":90,
"7.Steamed dumplings":150,
"8.Chicken drumsticks":120,
"9.Chicken Pakoras":120,
"10.American Chop Suey":200
}
continue_order = 1
total_cost, total = 0, 0
cart = []
while continue_order != 0:
option = int(input("Which item would you like to purchase?: "))
cart.append(option)
if option >= 10:
print('we do not serve that here')
break
elif option == 1:
quantity = int(input("Enter the quantity: "))
total = quantity * 150
print("The price is: ₹" + str(total))
elif option == 2:
quantity = int(input("Enter the quantity: "))
total = quantity * 120
print("The price is: " + str(total))
elif option == 3:
quantity = int(input("Enter the quantity: "))
total = quantity * 60
print("The price is: " + str(total))
elif option == 4:
qquantity = int(input("Enter the quantity: "))
total = quantity * 180
print("The price is: " + str(total))
elif option == 5:
quantity = int(input("Enter the quantity: "))
total = quantity * 150
print("The price is: " + str(total))
elif option == 6:
quantity = int(input("Enter the quantity: "))
total = quantity * 90
print("The price is: " + str(total))
elif option == 7:
quantity = int(input("Enter the quantity: "))
total = quantity * 150
print("The price is: " + str(total))
elif option == 8:
quantity = int(input("Enter the quantity: "))
total = quantity * 120
print("The price is: " + str(total))
elif option == 9:
quantity = int(input("Enter the quantity: "))
total = quantity * 120
print("The price is: " + str(total))
elif option == 10:
quantity = int(input("Enter the quantity: "))
total = quantity * 200
print("The price is: " + str(total))
total_cost += total
continue_order = int(input("Would you like another item? enter Yes--> (1) or--> No (0):"))
print('='*30)
print('='*30)
print("Your receipt:\n")
print("Date: " + str(x))
print("Name: " + name.title())
print("Adress: " + address)
print("Contact number: " + contact)
for option in cart:
print ("Item: %s. Price: %s") % (option, prices[option])
print("Quantity: ",quantity)
print("Total Price: ", total_cost)
print('='*30)
print("Thank you for shopping here, have a great day ")
print('='*30)
but i get an error line 95, in
print ("Item: %s. Price: %s") % (option, prices[option])
KeyError: 1
any solution or better ways to improve the code would be really great
Try using F-Strings. They let you format text far more easily. Here's an example.
x = "hello!"
print(f"shr4pnel says {x}")
>>> shr4pnel says hello!
The problem in this case is that option == 1. 1 isn't a key in the dictionary so nothing is output. Hope this helps. This is because the dictionary does not have 1 as a key. To access the item the dictionary would have to be formatted like this.
prices = {1: "burger", 2: "hot dog"}
print(prices[1])
>>> burger

Why is it that the list variables in this code gets values in them backwards? HP is the last assigned variable despite being there first in the list

I'm making a simple program (I am a beginner at python) where I fight a monster with random assigned values. I used 2 lists with 4 variables each depicting hp atk def and spd. They get assigned a random number of 10 to 15 and get multiplied by 2. I don't really know what I am doing wrong here.
import random
monsters = ["slime","goblin","troll","dryad","bard","clown"]
hp,atk,dfn,spd = 0,0,0,0
mhp,matk,mdfn,mspd = 0,0,0,0
stats = [hp,atk,dfn,spd]
mstats = [hp,atk,dfn,spd]
damage = 0
defend = 0
action = "none"
name = input()
print("Your name is " + name + ", time to battle!")
for x in stats:
stats[x] = random.randint(10,15) * 2
print("Your stats(hp/a/d/s): " + str(stats[x]))
for y in mstats:
mstats[y] = random.randint(10,15) * 2
print("Monster stats(hp/a/d/s): " + str(mstats[y]))
while stats[hp] > 0 or mstats[hp] > 0:
print("What will you do? 1 for attack, 2 for defend, others to give up")
action = input()
if action == "1":
damage = stats[atk] / 2 + random.randint(1,5)
mstats[hp] = mstats[hp] - damage
print("You slash the monster for " + str(damage) + " damage!" )
print("Monster HP: " + str(mstats[hp]))
damage = mstats[atk] / 2
stats[hp] = stats[hp] - damage
print("The monster slashes you for " + str(damage) + " damage!")
print("Your HP: " + str(stats[hp]))
if action == "2":
damage = mstats[atk] / 2 - random.randint(3,5)
if damage > 0:
stats[hp] = stats[hp] - damage
print("The monster slashes you for " + str(damage) + " damage!")
print("Your HP: " + str(stats[hp]))
if action != "1" and action != "2":
stats[hp] = 0
if stats[hp] < 0 or stats[hp] == 0:
print("You lose!")
if mstats[hp] < 0:
print("You win!")
Hopefully this code isn't a mess, I thank you all in advance if extra corrections can be given.

Loops in Python terminating Programm

I am new to coding and Python in general, and I can't figure this out.
I added loops so that the program does not terminate every time there is a typo, however I messed up something with the second loop presumably.
I think it might be connected to the whitespace, but I can't figure it out.
The Programm terminates after taking in the "calories_burned" variable.
def start():
print("""This is a Weight Calculator, please follow the instructions.""")
name = input("What is your name? ")
age = int(input("How old are you? "))
if 19 <= age <= 78:
height = float(input("How tall are you in cm? "))
current_weight = float(input("How much do you currently weigh? "))
goal_weight = float(input("How much do you want to weigh? "))
calories_consumed = int(input("How many calories did you consume today? "))
calories_burned = int(input("How many calories did you burn today? "))
def activity():
global rmr
activity_factor = input("Choose an activity factor: Sedentary, Lightly active, Moderately Active, Very Active ")
zif activity_factor == "sedentary":
rmr = int(round(((10 * current_weight) + (6.25 * height) - (5 * age) + 5) * 1.2))
if activity_factor == "lightly active":
rmr = int(round((10 * current_weight + 6.25 * height - 5 * age + 5) * 1.375))
if activity_factor == "moderately active":
rmr = int(round(((10 * current_weight) + (6.25 * height) - (5 * age) + 5) * 1.550))
if activity_factor == "very active":
rmr = int(round(((10 * current_weight) + (6.25 * height) - (5 * age) + 5) * 1.725))
else:
activity()
daily_deficit = int((rmr + calories_burned - calories_consumed))
print("Your daily deficit is: " + str(daily_deficit))
import numpy
mean_deficit = [daily_deficit]
calculation_mean_deficit = int(round(7500 / numpy.mean(mean_deficit)))
reach_goal = int(round((current_weight - goal_weight) * calculation_mean_deficit))
print(mean_deficit)
print(name + " it will take you " + str(calculation_mean_deficit) + " days to loose 1 kg.")
print(name + " it will take you " + str(reach_goal) + " days to reach your goal.")
choice = input("do you wish to continue Y/N?")
if choice == "n":
return
else:
start()
else:
print("Invalid age")
start()
start()
You don't call the activity() function anywhere in your code, so once the program collects the inputs it doesn't do anything else and exits.
Also it's "lose" not "loose"

Python - print name shows None

import re
import time
import sys
def main():
name = getName()
getOption()
nameForTicket, done = getTraveling(name)
price, destination = getWay()
fare = getFare()
seat = getSeat()
age = getAge()
totalcost = getTotalCost(price, fare, seat, age)
print("\n" + "Thank you " + name + " for flying us!" + "\n" + "The ticket price is: $" + str(totalcost) + "\n" + "The destination is: " + str(destination) + "\n" + "Ticket is for: " + str(nameForTicket).title())
main2(name, done)
def getName():
name = input("Welcome to Tropical Airlines! Please enter your name >>> ")
if not re.match("^[a-zA-Z ]*$", name):
print("Error, only letters allowed!")
getName()
elif len(name) > 15:
print("Error, Only 15 characters allowed!")
getName()
else:
print ("Welcome " + name.title())
return name
def getOption():
print("(I) Information" + "\n" + "(O) Order" + "\n" + "(E) Exit")
user_choice = input("Choose one of the following option >>> ")
if user_choice.upper() == "I":
displayInfo()
else:
if user_choice.upper() == "O":
return
else:
if user_choice.upper() == "E":
print("Thank you for visiting Tropical Airlines")
exit()
else:
print("Error")
getOption()
def displayInfo():
print("Thank you for choosing Tropical Airlines for your air travel needs." + "\n" + "You will be asked questions regarding what type of ticket you would like to purchase as well as destination information." + "\n" + "We also offer 50% discounted fares for children.")
getOption()
def getTraveling(name):
option = input("Who is the traveling person?" + "\n" + "(Y) You" + "\n" + "(S) Someone else")
if option.upper() == "Y":
nameForTicket = name
done = True
return nameForTicket, done
elif option.upper() == "S":
nameForTicket = getName2()
done = False
return nameForTicket, done
else:
print("Error")
getTraveling(name)
def getName2():
name2 = input("What is the travelling person name?")
if not re.match("^[a-zA-Z ]*$", name2):
print("Error, only letters allowed!")
getName2()
elif len(name2) > 15:
print("Error, Only 15 characters allowed!")
getName2()
else:
return name2
def getWay():
option = input("What kind of trip?" + "\n" + "(1) One way" + "\n" + "(2) Round trip")
if option == "1":
cost, destination = getDest1()
return cost, destination
elif option == "2":
cost, destination = getDest2()
return cost, destination
else:
print("Error")
getWay()
def getDest1():
option = input("Choose one of the following destination: " + "\n" + "(C) Cairns -- $200" + "\n" + "(P) Perth -- $250" + "\n" + "(S) Sydney -- $300")
if option.upper() == "C":
initialCost = 200
dest = "Cairns"
return initialCost, dest
elif option.upper() == "P":
initialCost = 250
dest = "Perth"
return initialCost, dest
elif option.upper() == "S":
initialCost = 300
dest = "Sydney"
return initialCost, dest
else:
print("Error")
getDest1()
def getDest2():
option = input("Choose one of the following destination: " + "\n" + "(C) Cairns -- $300" + "\n" + "(P) Perth -- $400" + "\n" + "(S) Sydney -- $500")
if option.upper() == "C":
initialCost = 300
dest = "Cairns"
return initialCost, dest
elif option.upper() == "P":
initialCost = 400
dest = "Perth"
return initialCost, dest
elif option.upper() == "S":
initialCost = 500
dest = "Sydney"
return initialCost, dest
else:
print("Error")
getDest2()
def getFare():
option = input("Choose one of the following type of fare: " + "\n" + "(B) Business -- Extra $200" + "\n" + "(E) Economy -- Extra $50" + "\n" + "(F) Frugal -- Free")
if option.upper() == "B":
fare = 200
return fare
elif option.upper() == "E":
fare = 50
return fare
elif option.upper() == "F":
fare = 0
return fare
else:
print("Error")
getFare()
def getSeat():
option = input("Choose one of the following type of seat: " + "\n" + "(W) Window -- $20" + "\n" + "(A) Aisle -- $15" + "\n" + "(M)Middle -- $10")
if option.upper() == "W":
seat = 20
return seat
elif option.upper() == "A":
seat = 15
return seat
elif option.upper() == "M":
seat = 10
return seat
else:
print("Error")
getSeat()
def getAge():
age = int(input("Enter the age, if the age is bellow 17, you will get 50% discount >>> "))
while age < 6 or age > 100:
print("Invalid age")
age= int(input("Enter the valid age >>>"))
return age
def getTotalCost(price, fare, seat, age):
if age <18:
finalCost = (price + fare + seat)/2
else:
finalCost = price + fare + seat
return finalCost
def loading():
for i in range(101):
time.sleep(0.02)
sys.stdout.write("\r%d%%" % i)
sys.stdout.flush()
def main2(name, done):
getOption()
nameForTicket = getTraveling2(name, done)
price, destination = getWay()
fare = getFare()
seat = getSeat()
age = getAge()
totalcost = getTotalCost(price, fare, seat, age)
print("\n" + "Thank you " + name + " for flying us!" + "\n" + "The ticket price is: $" + str(totalcost) + "\n" + "The destination is: " + str(destination) + "\n" + "Ticket is for: " + str(nameForTicket2).title())
main2(name, done)
def getTraveling2(name, done):
option = input("Who is the traveling person?" + "\n" + "(Y) You" + "\n" + "(S) Someone else")
if option.upper() == "Y":
if done == True:
print("You have already ordered ticket for you!")
getTraveling2(name, done)
elif done == False:
nameForTicket = name
done = True
return nameForTicket, done
elif option.upper() == "S":
nameForTicket = getName2()
return nameForTicket
else:
print("Error")
getTraveling2(name, done)
main()
Short story I was writing these long codes.
If from def main() in nameForTicket, done = getTraveling(name) I choose Y, the code shows the name instr(nameForTicket).title() for the def main() just fine.
but in def main2(): for the function getTraveling2(name, done) if I choose S, the str(nameForTicket2).title() in def main2(): will show None.
And the same happens if from main() I choose S, the main2() if I choose S will show none, and if I choose Y, it will display (Name, True)
how to fix it so the name will show based on the input for S?
In main2, change
nameForTicket = getTraveling2(name, done)
to
nameForTicket2 = getTraveling2(name, done)
because your print statement in main2 addresses str(nameForTicket2).title(), which is trying to print the title of nameForTicket2 when you set the result of the getTraveling2 method to nameForTicket instead. Therefore, the print statement gives you None since nameForTicket2 was never really defined.

Categories