This is just a simple game I tried to put together that asks you a couple questions and then automatically formats a new passcode out of the answers.
Since I am a beginner I'd like to know of some techniques I could use that would increase the efficiency of this code, and maybe remove the crazy amount of functions I've declared. Thank You!
minimum = 3
maximum = 10
name = input("What is your name? ")
def nameInput():
if len(name) < minimum:
print("Name is too small")
return nameInput()
elif len(name) > maximum:
print("Name is too large")
return nameInput()
nameInput()
food = input("What is your favorite food? ")
def foodInput():
if len(food) < minimum:
print("Enter a food name longer than " + (food))
return foodInput()
elif len(food) > maximum:
print("Enter a food name shorter than " + (food))
return foodInput()
foodInput()
birthday = input("What is your date of birth? (mmddyyyy) ")
nameIndex = name[0:2]
foodIndex = food[2: ]
birthIndex = birthday[0:3]
passcode = nameIndex + foodIndex + birthIndex
print("Your password is " + passcode)