13,734,472 members
See more:
I don't understand what i'm doing wrong here:

This is the code challenge:

"I'm going to create a variable named time. It'll be an integer for the current hour (well, what I want the current hour to be).
I need you to make an if condition that sets store_open to True if time is in store_hours. If time isn't in store_hours, set store_open to False. You'll probably have to use if, else, and in to solve this one."

this is what i have typed in:

```store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
if "time" in store_hours:
store_open = True
else:
store_open = False```

But i keep getting an error message that says :
"Bummer! `store_open` is not True."

What I have tried:

Everything.

I tried retyping it all.
I went back and re -watched the lesson and learned nothing new.
Posted 11-Oct-16 14:30pm
Updated 11-Oct-16 23:37pm
v2
Richard MacCutchan 12-Oct-16 4:22am

You are looking for the string "time" in the array of integers, so that will never work. You need to create a variable named `time` that will be allocated some integer value indicating what the hour is.
Richard MacCutchan 12-Oct-16 6:02am

My virtual :thanks:
CPallini 12-Oct-16 5:38am

My virtual 5.

## Solution 2

Following Richard's suggestion:
Quote:
You are looking for the string "time" in the array of integers, so that will never work. You need to create a variable named time that will be allocated some integer value indicating what the hour is.

try
```store_open = None
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
time = 13
if time in store_hours:
store_open = True
else:
store_open = False

print store_open```

## Solution 1

Try:
```store_open = None
store_open = False
store_hours = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
if "time" in store_hours:
store_open = True
else:
store_open = False```

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Debugging in Python | Python Conquers The Universe[^]
Debugging Python Like a Boss - The Zapier Engineering Blog - Zapier[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.

[Update]
Quote:
That doesn't work.
The change I gave you is about the error message you claim "Bummer! `store_open` is not True.".
I never said I did not suspect the `if` statement to be wrong.
And you need to learn the debugger soon.

By the way, giving error position also help us to see what is wrong.
I don't see any reason to get your error message in the code you provided, even the error message itself is weird.
v5
Daniel Choban 11-Oct-16 22:20pm

That doesn't work.
Dave Kreskowiak 11-Oct-16 22:51pm

Yeah, this is your homework. What he gave you is not real code that will copy'n'paste and run. You have to write the proper code yourself and you're not going to get anyone to do that for you.
Richard MacCutchan 12-Oct-16 5:16am

It's not an error message, it's the message his code prints elsewhere when checking the value of `store_open`. See my comment above.

Top Experts
Last 24hrsThis month
 OriginalGriff 171 Richard MacCutchan 140 Patrice T 121 CPallini 75 Dave Kreskowiak 40
 OriginalGriff 5,002 Richard MacCutchan 1,644 Patrice T 1,291 CPallini 1,119 Dave Kreskowiak 1,080