-1

The hold section isnt printing im not getting an error or anything like that

#TEXT SECTION

#Start

textMorn= "It's 8 in the morning, the sunshine comes up and you slowly open your eyes. You realize it's monday morning, so you get up and start making some breakfast. You munch down a nice bowl of cereal, consisting of mini wheats and milk. Once it's finished , you wash the bowl and spoon and brush your teeth. You check the time while brushing your teeth and see that it's 8:27, and you woke up an hour later than you were supposed to. You don’t want to be late for school, so you think about taking public transit. It is a little pricey though, because you need to save up for public transit after school so you can get home earlier. You can also walk to school, but you will be 10 minutes late. What do you choose? Type WALK or TRANSIT."

morn1=str(input(textMorn))

#First Choice

textWalk=("You walk to school, and it's a long walk since you live 25 minutes away. You come to class late, and everyone is looking at you when you walk in. It doesn't matter though, since you still got to class. Your first period is math, and during the lesson 30 minutes in, and all the sudden you feel like you need to go to the washroom to take a big dump. You really don't want to skip 15 minutes worth of class, but you feel really bad right now. Do you want to get to the washroom, or hold it in for the rest of class. Type HOLD or GO.")

walk=str(textWalk)

textTransit=str("You take public transit, even though it means that you can't get home early. You go to the bus stop and wait for a few minutes. 3 minutes later, a bus comes by, you get on and get to school in 10 minutes. You come to class just on time. Your first period is math, and during the lesson 40 minutes in, and all the sudden you feel like you need to go to the washroom to take a big dump. You really don't want to skip 15 minutes worth of class, but you feel really bad right now. Do you want to get to the washroom, or hold it in for the rest of class.Type HOLD or GO.")

transit=str(textWalk)

#Second Choice

go=("""You ask the teacher to go to the bathroom, and he allows you to go right away. You walk across the halls and go to the washroom. When you step in, it reeks of smoke. You realize there is people vaping in the bathroom, so you go to the sinks and check, and unsurprisingly you see 2 guys that look like seniors vaping at the sinks. You can either ignore them or tell them to get out of the washroom. Type IGNORE or TELL.""")

goText=str(go)

golate1=str("""You ask the teacher to go to the bathroom, and he reluctantly allows you to go right away since you were already late for class. You walk across the halls and go to the washroom. When you step in, it reeks of smoke. You realize there's people vaping in the bathroom, so you go to the sinks and check, and unsurprisingly you see 2 guys that look like seniors vaping at the sinks. You can either ignore them or tell them to get out of the washroom. Type IGNORE or TELL.""")

holdText=("""You hold it in and try to focus on class, but you didn't get any further than expected. Class ends, and you rush to the washroom. Once you’re done with your business, you go to the next class 5 minute late and get through english class. Lunch time starts and you get a call from your mom, telling you to stop being late to class all the time. You simply ignore her, since you feel like there was nothing you could do about it. Now it's time to focus on lunch. You feel like you don’t really want to talk to anyone, but you don't want to ditch your friends during lunch. What do you choose, lunch alone or with your friends? Type FRIENDS or ALONE.""")

hold1=str(holdText)

print("line 67")
if morn1=="TRANSIT":
    input(transit)
    if transit=="HOLD":
        input(hold1)
if morn1=="WALK":
    input(walk)
    if walk=="GO":
        input(go)
Random Davis
  • 6,662
  • 4
  • 14
  • 24
p1p1p1
  • 11
  • 3
  • 1
    You're not assinging the input from `input(transit)` anywhere; you probably meant to do `transit = input(textTransit)` or something like that - since you're checking the content of `transit` below it. – MatsLindh Jan 04 '21 at 21:49
  • 1
    transit is “You take...” and you never change it, so the if will always be False. – quamrana Jan 04 '21 at 21:50

1 Answers1

1

The issue is that input(transit) does not change transit; it just displays transit as an input prompt, but then throws away whatever the user typed. You have to store the output of the input statement in a variable. The simplest fix would be to replace that line with transit = input(transit), but a better fix would be to hold the result in a different variable:

if morn1=="TRANSIT":
    transit_input = input(transit)
    if transit_input =="HOLD":
        input(hold1)

If you want to not have to type things in all caps, by the way, you can do a case-insensitive comparison by converting everything to the same case:

if morn1.lower() == "transit":
    transit_input = input(transit)
    if transit_input.lower() == "hold":
        input(hold1)
Random Davis
  • 6,662
  • 4
  • 14
  • 24
  • Ok, I tried it and it is working! To clarify, i should put the old variable into a new one, so it can print, is that correct? – p1p1p1 Jan 04 '21 at 22:06
  • The reason why `hold1` never printed was because it was impossible for `transit=="HOLD"` to be `True`, since `transit` was never being set to anything besides `str(textWalk)`. So, in order for that condition to actually be `True` (and thus the code to print `hold1` would execute), you have to either store the user's input in `transit` for the `if` statement to work, or store the input in another variable (in my example I used `transit_input`), and _also_ change the `if` statement to check that variable. – Random Davis Jan 04 '21 at 22:58