Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Python
name = input("Enter Name: ")
a = input( name + " would you like your fortune told? ")
if  a == "no":
  print("ugh fine(ノಥ益ಥ)ノ ┻━┻")
elif a == "yes":
  print("pick a number between 1-10")
# this is the code but when I when I put something like
elif a == "1":
print("blah blah blah")
# it wont print that
(this is Python don't know what version)


What I have tried:

dont know i new to code but i did try to do syntax
Posted
Updated 5-Aug-22 22:10pm
v2

I think this looks like Python 3 to me.

I am guessing the problem is that Python expects a statement in your elif a == "1": block. But you have not put a statement there. So, to compile and move on from this statement, put a pass.

But, even if you do, nothing would work. For two reasons:
1. You are not reading the value for the number (you did not use the input method, again)
2. You are using elif to check values and then take two steps.

Note that when you ask the user to put in the number, they put in, and then you move to the next line. But elif will not execute because one statement within this if...elif...else structure has been executed. Python will not check any other conditions or execute the code. So you can either put the input statement within this block (elif a == "yes":) or read it after the print("blah blah blah") line.

Read these for more on the topic:
4. More Control Flow Tools — Python 3.10.6 documentation[^] (if...else, pass statement, etc.)
 
Share this answer
 
v3
The issue is that you have not indented the code correctly. And indentation is not just quite important, it is absolutely essential in Python. Also the last elif is redundant as it does not belong to the original question.

So you need something like:
Python
name = input("Enter Name: ")
a = input( name + " would you like your fortune told? ")
if  a == "no":
  print("ugh fine(ノಥ益ಥ)ノ ┻━┻")
elif a == "yes":
  print("pick a number between 1-10")
# you need code here to input the number and then start a new if block
  number = input("number")
  if number == "1":
    # do something 
  elif number == "2":
    # do something else
    # etc. 
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900