Press any key to continue....**In Console Escape from if statement

Hello.
In Console, Python.

import os
import sys

GirlName = “Victoria”
if dbName != “Emery”:
break #<=== Here, I want to (**Press any key to continue…**In Console) Escape from if statement?? Here, Escape the code below from being executed…Press any key to continue…

BoyName = “Benjamin”
if BoyName != “Andrew”
break

BabyName = “Oliver”
if BabyName != “Noah”
break

Hello,

when entering Python scripts:

format_code

This way, the code appears as it does on your console giving you the opportunity to verify and double check that it has been entered correctly (tabs are where they should be, for example, since Python is a very tab-centric language).

2 Likes

I did as you said, but an error occurred.

import subprocess
import os
import sys

GirlName = “Victoria”

if GirlName != "Emery":

BoyName = “Benjamin”

if BoyName != "Andrew"

BabyName = “Oliver”

if BabyName != "Noah"

Please copy your ENTIRE code as per the instructions - not bits and pieces. Make sure that it appears as it does on your console.

fyi …, a case statement might also work for this application:

name = input('Please enter a name: ')

match name:

            case 'Emery':
                print('Emery is the correct name.')  
                
            case 'Andrew':
                print('Andrew name was entered.')

            case 'Noah':
                print('Noah name was entered.')           

            case _:
                print("Not a valid name!")

print('\nSuccessfully processed names!')  

1 Like

Variable is
1.GrilName
2.BoyName
3.BayName

Each Variable Different…

How to do i solve?

instructions_for_entering_your_code

import subprocess
import os
import sys

GirlName = “Victoria”
if GirlName != “Emery”:

BoyName = “Benjamin”
if BoyName != “Andrew”

BabyName = “Oliver”
if BabyName != “Noah”

There is one variable (name) in Your code.

I want Three variable (grilname, boyname, babyname)

If the if statement is not satisfied in GrilNmae variable, you must escape without executing the code below(BoyName, BabyName ).

There is one variable (var1) in Your code.
I want Three variable (grilname, boyname, babyname)

Sorry, if you are not able to follow instructions, I cannot help you.

1 Like