Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


want to make a program

i want to make a program which take a input of a number and then it check if the number is in the variable name lists=[1,2,3,4,5] then print yes if it doesn't exist print no.some brief detail. lists=[1,2,3,4,5] #if these number in input then print yes if no then print no

Steven Parker
Steven Parker
230,230 Points

What aspect of the task is causing an issue? Have you written any code yet? Please give the problem a good-faith attempt and post your code.

Also, can you provide a link to the course challenge or video?

for item in lists:
  if answer==item:

1 Answer

vikas pal, this code should do what you want if I understand you correctly. It takes an input and checks if the input is in my_list.

my_list = [1, 2, 3, 4, 5]

answer = input('enter ')

if answer in my_list: