0

I am having trouble with my code

I am having trouble with my code I am learning python but it is teaching me in python 2 format while the program I am writing the code in is python 3 which for the most part is the same just some subtle changes that I could find on the internet like in python 2 you use raw_input, %s, and % for things as far as user input while in python 3 you use input, {}, and .format() so the big problem that I am running into is that I am using if, elif, and else statements but before I can see if I made anymore mistakes in my code I get and error of unexpected indent at line 19 even though I was taught to use 2-4 indent spaces and on python it is mainly 4 I am just trying to get a better grasp on my errors and understanding why I get certain error codes plus I can't find anything outside of solo learn and other sites like it any help would be greatly appreciated # this line gets the date and time from the currnet os and imports it to the program from datetime import datetime # this line specifies that I would like it to pull the date and time from the current time that I am opening and running the program now = datetime.now() # this excutes the above commands in the format laid out and will display like so in the programm print ("{}/{}/{}, {}:{}:{}".format(now.month, now.day, now.year, now.hour, now.minute, now.second)) # this will take user input and store to print the results the the user inputs name = input("What is your name?") # this takes user input and stores it to print the results from the users input animal = input("What is your favorite animal?") # this takes user input and stores it to print the results from user inputs color = input("What is your favorite color?") # this will print the messages along with all the users input print ("Ah, so your name is {}, your favorite animal is a {}, " \ "and your favorite color is {}.".format(name, animal, color)) # this defines the answer based on user inputs and gives them the commands the program wishes to excute answer = input ("Type yes or no then hit

11th May 2018, 10:29 PM
Aaron Doran
Aaron Doran - avatar
4 Respuestas
0
sorry looks like it didn't post all of it I ran out of characters
11th May 2018, 10:30 PM
Aaron Doran
Aaron Doran - avatar
0
# this line gets the date and time from the currnet os and imports it to the program from datetime import datetime # this line specifies that I would like it to pull the date and time from the current time that I am opening and running the program now = datetime.now() # this excutes the above commands in the format laid out and will display like so in the programm print ("{}/{}/{}, {}:{}:{}".format(now.month, now.day, now.year, now.hour, now.minute, now.second)) # this will take user input and store to print the results the the user inputs name = input("What is your name?") # this takes user input and stores it to print the results from the users input animal = input("What is your favorite animal?") # this takes user input and stores it to print the results from user inputs color = input("What is your favorite color?") # this will print the messages along with all the users input print ("Ah, so your name is {}, your favorite animal is a {}, " \ "and your favorite color is {}.".format(name, animal, color)) # this defines the answer based on user inputs and gives them the commands the program wishes to excute answer = input ("Type yes or no then hit enter") # this is where the error occurs as unexpected indent even though I have four indent spaces if answer == "yes" or answer == "y" # this is supposed to print Okay great! if the user inputs yes or y print ("Okay great!") # this is sppoused to take user input if answer is not yes or y but is no or n elif answer == "no" or answer == "n" # this is sppoused to print Oh sorry about that. if user inputs no or n print ("Oh sorry about that.") #this supposed to excute and print You did not select yes or no please try againg if user answered in anyway besides yes, y, no, or n else: print ("You did not select yes or no please try again")
11th May 2018, 10:30 PM
Aaron Doran
Aaron Doran - avatar
0
hi, can you put a link to your code ?
11th May 2018, 11:27 PM
MBZH31
MBZH31 - avatar
0
yeah sorry it took so long to reply I switch between here and codecademy
27th Aug 2018, 7:05 AM
Aaron Doran
Aaron Doran - avatar