Hello,
I tried to make a simple program that interacts with the user and asks about his gender. However, I cannot seem to make it work past line 7. Could someone help me please ? Thanks a lot :)
print ("Hello, nice to meet you. What's your name ?")
name = input()
print ("Hi, " + name)
print ("That's a beautiful name.")
print ("As for me, my name is Ali, I am a boy.")
print ("Are you a boy as well ?")
while True:
prompt1 = input()
if prompt1 == "yes":
print("Hey bro")
elif prompt1 =="no":
print ("Hi sis")
else:
print ("Huh")
2 7982
Hello,
I tried to make a simple program that interacts with the user and asks about his gender. However, I cannot seem to make it work past line 7. Could someone help me please ? Thanks a lot :)
print ("Hello, nice to meet you. What's your name ?")
name = input()
print ("Hi, " + name)
print ("That's a beautiful name.")
print ("As for me, my name is Ali, I am a boy.")
print ("Are you a boy as well ?")
while True:
prompt1 = input()
if prompt1 == "yes":
print("Hey bro")
elif prompt1 =="no":
print ("Hi sis")
else:
print ("Huh")
I added the indentation and it seems to be working fine (python 3). What isn't working for you? - print ("Hello, nice to meet you. What's your name ?")
-
name = input()
-
print ("Hi, " + name)
-
print ("That's a beautiful name.")
-
print ("As for me, my name is Ali, I am a boy.")
-
print ("Are you a boy as well ?")
-
while True:
-
prompt1 = input()
-
if prompt1 == "yes":
-
print("Hey bro")
-
elif prompt1 =="no":
-
print ("Hi sis")
-
else:
-
print ("Huh")
To reduce line.
Also '\n' is a string break for python, you can called it 'enter'. -
print ("Hello, nice to meet you. What's your name ?")
-
name = input()
-
print("Hi, " + name+ "\n That's a beautiful name. \n As for me, my name is Ali, I am a boy.\n Are you a boy as well ?")
-
while True:
-
prompt1 = input()
-
if prompt1 == "yes":
-
print("Hey bro")
-
elif prompt1 =="no":
-
print ("Hi sis")
-
else:
-
print ("Huh")
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: swaroophr |
last post by:
Which of switch statement and if-else statement takes less time to
execute?
|
by: hanumizzle |
last post by:
I have used Perl for a long time, but I am something of an experimental
person and mean to try something new. Most of my 'work' with Vector
Linux entails the use of Perl (a bit of a misnomer as it...
|
by: paul |
last post by:
Hi all,
I've been handed some code and, unless I've got the numbering of
parentheses wrong, one of the functions has a curious if-else
statement. The thing compiles but is it right?
I know the...
|
by: juan-manuel.behrendt |
last post by:
Hello together,
I wrote a script for the engineering software abaqus/CAE. It worked
well until I implemented a selection in order to variate the variable
"lGwU" through an if elif, else...
|
by: clear1140 |
last post by:
Good day!!
I was wondering if it is possible to put an if else statement inside a where clause of an sql statement... you see i would like my update statement to do this:
update...
|
by: MicaK |
last post by:
Good Morning,
I am new to this forum, and extremely new to VBA, so there may be a very simple explanation to this. I also apologize if I am giving you and excessive amount of detail. I have a...
|
by: maveri4201 |
last post by:
I have written a php script (test3.php), which I attached as a text file. Its includes are also attached as text files. I'm trying to run the script here: http://www.wondergy.com/phptestbed/test3.php...
|
by: Robert Ingles |
last post by:
I apologize for my current lack of knowledge and hope that someone will be kind enough to give me some additional help.I posted a question regarding "Record does not exist, open add record form". I...
|
by: Joshua Billings |
last post by:
I am working on a programming assignment, and I can't figure out what is wrong with these lines of code.
if ad > 6:
rectAD.setFill("red")
if ad <= 3:
rectAD.setFill("red")
else:
...
|
by: tastingoo |
last post by:
Hi,
I'm having problems accessing the worksheet after creating the worksheet in an IF statement. For some reason, if I create the worksheet in the else statement, my $rxsheet address is gone...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |