I made this code (Its in python)

Sort:
Avatar of crystal0192

import time
import random
fruit1 = input("What is a fruit you like?  ")
while fruit1.isalpha() == False:
  print("Your fruit must contain only alphabetical characters! It cannot include spaces or digits.")
  fruit1 = input("What is a fruit you like?  ")
fruit2 = input("What is another fruit you like?  ")
while fruit2.isalpha() == False:
  print("Your fruit must contain only alphabetical characters! It cannot include spaces or digits.")
  fruit2 = input("What is another fruit you like?  ")
fruit3 = input("What is another fruit you like?  ")
while fruit3.isalpha() == False:
  print("Your fruit must contain only alphabetical characters! It cannot include spaces or digits.")
  fruit3 = input("What is another fruit you like?  ")
fruit4 = input("What is another fruit you like?  ")
while fruit4.isalpha() == False:
  print("Your fruit must contain only alphabetical characters! It cannot include spaces or digits.")
  fruit4 = input("What is another fruit you like?  ")
fruit5 = input("What is another fruit you like?  ")
while fruit5.isalpha() == False:
  print("Your fruit must contain only alphabetical characters! It cannot include spaces or digits.")
  fruit5 = input("What is another fruit you like?  ")
fruits = [fruit1, fruit2, fruit3, fruit4, fruit5]
print("The program will now determine your favorite fruit using an AI model. You will need to answer these quetions to continue:")
color = input("What is your favorite color?  ")
while color.isalpha() == False:
  print("Your favorite color can only include alphabetical characters! No spaces, digits, or special characters!")
  color = input("What is your favorite color?  ")
gender = input("Are you a boy, girl, or other (Type 'boy', 'girl', or 'other', do not use anything besides those!)?  ")
while gender.isalpha() == False:
  print("Your gender can only include alphabetical characters! No spaces, digits, or special characters!")
  gender = input("Are you a boy, girl, or other (Type 'boy', 'girl', or 'other', do not use anything besides those!)?  ")
animal = input("What is your favorite animal?  ")
animal = animal.replace(" ", "")
while animal.isalpha() == False:
  print("Your favorite animal can only include alphabetical characters and spaces! No digits or special characters!")
  animal = input("What is your favorite animal?  ")
  animal = animal.replace(" ", "")
food = input("Which food do you like the most: cake, hamburger, rice, or cookie?  ")
while food.isalpha() == False:
  print("Your favorite food can only include alphabetical characters! No digits, spaces, or special characters!")
  food = input("Which food do you like the most: cake, hamburger, rice, or cookie?  ")
print("Confirm this data by typing 'Yes', anything else means that the data is invalid!")
time.sleep(1)
print(f"Your favorite color is: {color}")
time.sleep(3)
print(f"Your gender is: {gender}")
time.sleep(3)
print(f"Your favorite animal is: {animal}")
time.sleep(3)
print(f"Your favorite food from the list was: {food}")
time.sleep(3)
confirm = input("Is this data correct ('Yes' if correct, 'No' if incorrect!)?  ")
if confirm.lower() == "yes":
  favfruit = random.choice(fruits)
  print(f"Your favorite fruit is: {favfruit}")
  time.sleep(3)
  print("Help us improve our AI, please answer the following questions:")
  correct = input("Was the model correct? ")
  if correct.lower() == "no" or correct.lower() == "nope" or correct.lower() == "nuh uh":
    print("We are sorry for the mistake!")
    input("What was the correct answer?  ")
    input("How can the model be improved? ")
    print("Thanks for your feedback, have a great day!")
  elif correct.lower() == "yes" or correct.lower() == "yup" or correct.lower() == "yeah":
    print("Hooray!")
    input("How can the model be improved? ")
    print("Thanks for your feedback, have a great day!")
  else:
    print(f"{correct} is unrecognised, please enter either 'Yes' or 'No'!")
else:
  print("If the data is inaccurate, please rerun the program and enter correct information, thank you!")

How can it be improved (I am a beginner so I don't know that much, this is the most complex program ive ever made!)

Avatar of crystal0192

its supposed to be funny, i do know it isnt AI

Avatar of ThePersonAboveYou

strings

Avatar of AmericanChadAGC

massive code

Avatar of crystal0192

you can run the code on this website (you need to delete the existing code and then copy and paste):

https://www.programiz.com/python-programming/online-compiler/

Avatar of frijol-y-pan

Wow!

Avatar of frijol-y-pan

I just ran it, very nice!

Avatar of crystal0192

thank you, any suggestions?

Avatar of frijol-y-pan

Not really, it’s very well-made!

Avatar of crystal0192

thanks!

Avatar of crystal0192

I updated it a little, i'll repost the code after I have made significant changes

Avatar of crystal0192

bump!

Avatar of Caspar_Is_Better

That is the most amazing code I have ever seen! I am a software developer, and I thought that code was amazing for a beginner! Great job, crystal0192!

Avatar of crystal0192

thanks

Avatar of burgentruck77
W python
Avatar of Leander_Is_Better

ur so sigma

Avatar of Leander_Is_Better

bump

Avatar of Miin1500

Feels funny

Avatar of Miin1500

At least i know python

Avatar of MagnusCapivaralsen1

What is it for?