+ 6
Can you help me with smart parking lot solved question?
I've been stuck on this for 2+ hours so far
46 ответов
+ 7
+ 4
Share your code
+ 4
# Take the number of available spaces as an input
spaces = 20
# Display message if spaces are available
if spaces > 0:
print("Available spaces")
# Display a different message if spaces are not available
else:
print("Sorry, the parking lot is full")
+ 4
AYESHA NOOR , don't plagiarize the answer/response that is already shared by Kyo.
If you have nothing to answer, please don't spam.
Shalom Polo, please create your own question and share the code you have created for your project to get further help from the community.
+ 2
Junior, thank you so so much for the help, I used what you told me and it totally worked, and I now understand how it does, thank you
+ 1
Trist Please share your attempt aswell
+ 1
Trist Is this a sololearn challenge by the way?
Why are you hard-coding the input? you should probably use input() function i would assume. If there are -spaces that means theres available spaces? That doesnt sound right to me you should probably switch the sign the other way.
+ 1
Trist Okay
+ 1
okay, thats good.
We can also plan out our code using logic like this. Focus on logic and not syntax if your doing pseudocode.
ask user for spaces
if spaces > 0
print “Available Spaces”
else
print “Sorry, the parking lot if full”
+ 1
Kyo Okay your hard-coding meaning that value isnt changing like a constant. notice the inputs changing? we dont just want the user input to be 20, we want it to be anything.
spaces = int(input())
+ 1
Kyo Sorry, meant hard-coding a value not hard-coding as in your whole code just that value
+ 1
Kyo Yes since you SET the value as 20 any other number is not valid input that you try and put. ONLY 20 is while 0 was another input thats why that error was occuring
0
What is the question?
0
Ok one sec both of you, I do all of my work on my computer
0
Ok, so it says "A smart parking lot displays different messages to the visitor based on the number of available spaces."
Then it says
Task
"Complete the program to inform the user about available spaces in the parking lot"
0
This is what I put
# Take the number of available spaces as an input
spaces = 20
# Display message if spaces are available
if spaces < 0:
print("Available spaces")
# Display a different message if spaces are not available
else:
print("Sorry, the parking lot is full")
0
Seems good enough
0
@Junior pls help if you can
0
Same to the other guy