Jump to content

nighthawk454

Member
  • Posts

    8
  • Joined

  • Last visited

Reputation Activity

  1. Like
    nighthawk454 got a reaction from Overkilled in Can someone help me with Python   
    Going into separate branches can be done by 'nesting' multiple if/else statements inside of each other.
     
    If/Else gets you two branches per question - one for 'yes' and one for 'no'. Then, for each subsequent question you get another two branches. You can then make flowcharts that look like this shape (imagine the numbers are questions):
     

     
     Here's an example that closely mimics your flowchart: 
    # This function is just to help out getting input# from the user. By writing it up here once, the # rest of the code can be cleaner and more readable.def askUser(question): answer = input(question + "? ").lower() if answer == "yes": return True elif answer == "no": return False else: print("Please answer yes or no.") askUser(question)# TROUBLE SHOOTER CODE STARTS HEREprint("Nice to meet you, " + input("What is your name? "))print("Welcome to my troubleshooter\n") if askUser("turns on"): print("Great") if askUser("iPhone 5 or later"): print("unsupported") else: if askUser("device specific"): print("forums") else: if askUser("iOS 7.1 or later"): print("update") else: if askUser("hard reboot"): if askUser("fixed?"): print("Great!") else: print("???") else: print("hard reboot")else: if askUser("physically damaged"): print("RMA") else: print("???") Give this code a try by saving in in a ".py" file and running it in Python. You should be asked different branches of questions depending on your answers. 
     
     
    Side note, props on using Python 3. 
×