Use and meaning of in in an if statement

0 votes

In an example from Zed Shaw's Learn Python the Hard Way, one of the exercises displays the following code:

next = raw_input("> ")
if "0" in next or "1" in next:
    how_much = int(next)

I'm having a hard time understanding the meaning of in in this statement. I'm used to using if statements, such as in javascript, where the syntax is something like:

var = 5;
if (var > 3) {
    //code  to be executed
}

Is this if / in statement (in python) the same as if() in javascript?

Finding an answer to this has been tricky because the in is such a short string to narrow down an answer via search engine, and I don't know the proper name for its operation.

Apr 22, 2022 in Python by Edureka
• 13,620 points
504 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
0 answers

Python's equivalent of && (logical-and) in an if-statement

This is not  working : if cond1 && cond2: Can ...READ MORE

May 20, 2022 in Python by Kichu
• 19,040 points
330 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,720 points
2,372 views
+1 vote
5 answers

how to exit a python script in an if statement

Instead of using the normal UTF-8 encoding, ...READ MORE

answered Jul 4, 2023 in Python by bodymist
• 140 points
355,788 views
0 votes
1 answer

Break for loop in an if statement

You'll need to break out of each ...READ MORE

answered Oct 23, 2018 in Python by SDeb
• 13,300 points
883 views
0 votes
1 answer

How to break for loop in an if statement

You can break out of each loop ...READ MORE

answered Nov 16, 2018 in Python by Jino
• 5,820 points
3,044 views
0 votes
1 answer

How to use nested if else statement in python?

The working of nested if-else is similar ...READ MORE

answered Nov 19, 2018 in Python by Nabarupa
1,297 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,468 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP