mercredi 6 janvier 2016

If-else statement not working in code, cant find a solution *PYTHON 3.5.1* [duplicate]

This question already has an answer here:

Ive got my code all here, and the else is for some reason not working:

troubleshoot2 = input("What brand is your phone?")

if troubleshoot2 == "apple":

troubleshoot3 = input("Which Iphone is it?")

 if troubleshoot3 == "iphone 5" or "iphone 5s" or "iphone 6" or "iphone 6s":

print ("Here are the options we have available for troubleshooting      your",troubleshoot3, ":", "http://ift.tt/1JtLPx0")

else:

print ("I'm sorry but we currently do not have any answers for your inquiery. We will forward this to our tech support and get back to you asap.")


elif troubleshoot2 == "samsung":

troubleshoot4 = input("Which Samsung Galaxy is it?")

if troubleshoot4 == "galaxy s5" or "galaxy s5 mini" or "galaxy s6" or "salaxy s6 edge":

print ("Here are the options we have available for troubleshooting your", troubleshoot4, ":", "http://ift.tt/1JtLNoR")


else:

print ("I'm sorry but we currently do not have any answers for your inquiery. We will forward this to our tech support and get back to you asap.")

What I want it to do is print the "we're sorry" message when the user inputs something that is not an option, for example "galaxy s4", however if I put galaxy s4 it will give me the normal output message for existing responses

Does anyone know how to fix this?

Thanks :-)

This is different from other users questions as I also need it to write the users input into a text file every time it is something we don't have available, for example "galaxy s4" would need to be written to a text document, and this must apply to all things missing. They also need to be on separate lines in the txt file.

I know this is dumb but I struggle finding solutions from other peoples codes with totally different purposes, so even if someone had the two similar functions solved, id get confused as I wouldn't get how to embed it into my code (im only half a year into the computing A-level) Thanks guys :-)

Aucun commentaire:

Enregistrer un commentaire