The outcomes of my elif statement wont work

I can’t get a response out of this when I’m using an input.
This works:
b = (“1”)
if b == (“1”):
print(“h”)
elif b == (“0”):
print(“j”)
This doesn’t work:
b = input(“g”)
if b == (“1”):
print(“h”)
elif b == (“0”):
print(“j”)

Hello, @Sector_77, please use code-block when posting code in the forum or use </> toolbar in the editor, like this:

```
copy-paste your code here
```

When I run your code, it is just run fine and has no error. Please give more detail on what are you trying to do, what are you expect your code do?

b = "1"
if b == ("1"):
    print("h")
elif b == ("0"):
    print("j")

b = input("g")
if b == ("1"):
    print("h")
elif b == ("0"):
    print("j")

Maybe you confuse with input()
The input() function takes input from the user and returns it.
Example:

name = input("Enter your name: ")
print(name)

# Output
# Enter your name: Jonas
# Jonas

Maybe you need to type your answer when terminal/cmd.exe/console show "Type input here: " text on the screen:

b = "1"
if b == ("1"):
    print("Good Morning")
elif b == ("0"):
    print("Good Night")

b = input("Type input here: ") # if you input 1 here it will be print 'Good Morning' and if your input 0 it will print Good Night
if b == ("1"):
    print("Good Morning")
elif b == ("0"):
    print("Good Night")

# Output
# Good Morning
# Type input here: 0
# Good Night

you can learn input() here:

Hope it will help

There is no need to put round brackets around characters like this:

b = ("1")  # What??? Brackets are pointless here.
b = "1"    # Much better.

if b == ("1"):  # No need for brackets.
if b == "1":    # Much better.

Use round brackets (parentheses) for function calls:

print(b)  # Call the function print

or for grouping complex expressions to change the order of calculation:

a = 1 + 4 * 10
print(a)  # prints 41
b = (1 + 4) * 10
print(b)  # prints 50

Also, it is never useful to say “this doesn’t work”. We’re not mind-readers. You need to tell us what “doesn’t work” means for you, and what happens when you try it.

Do you get an error? Your computer caught fire? Something else?

What did you type at the input() prompt?

Yes sorry I should explain. When ever I put in 1 or 0, It simply just doesn’t give response. It doesn’t print anything or do anything.

It’s working now, I don’t know what happened.

By Laiden Jonas via Discussions on Python.org at 31Mar2022 22:13:

It’s working now, I don’t know what happened.

You could post you current code and we could compare it to what you
posted before. Not that I saw anything wrong with what you posted
before.

It does help to print() out the exact values of what you’re working
with (and to show them to us if that doesn’t help), example:

b = input("g")
print("b =", repr(b))
if b == .........

Note the use of repr(), which returns a string representing the value
more precisely. A value for programmers (you). For basic types it
usually returns text you could use directly in Python to get that value.
By contrast, this:

print("b =", b)

implicitly calls str(b) to get what to print for b, and that can be
more ambiguous (for example, trailing whitespace will not be very
evident).

Cheers,
Cameron Simpson cs@cskk.id.au