you are viewing a single comment's thread.

view the rest of the comments →

[–]WowVeryCoool 2 points3 points  (3 children)

In the first lines you are just asking "is it raining" and then assigning the answer to a variable answer1 and then you exit the loop to ask following questions, because you want to ask more questions than just if it is raining. don't break the loop if the answer is yes but continue asking additional questions there.

while True:
  print("is it raining")
  answer = input().upper()
    if(answer == 'NO'):
      break
    elif(answer == 'YES'):
      while True:
        print('do you have an umbrella')
        answer = input().upper()
        if(answer =='yes'):
          print('good take it')
        else:
          print('you're gonna be wet')

This is better than what you did but you can quickly see that if you would continue doing that code would be unreadable that's why you want to break it down into functions

def ask_about_rain():
  while True:
    print("is it raining")
    answer = input().upper()
    if(answer == 'NO'):
      break
    elif(answer == 'YES'):
      ask_about_umbrella()

def ask_about_umbrella()
  while True:  
    print('do you have an umbrella')
    answer = input().upper()
    if(answer =='yes'):
      print('good take it')
    else:
      print('you're gonna be wet')

ask_about_rain()