0
What is wrong here? (Python)
It will output True if steps is greater than 1000 and it will output True if active_minutes is greater than 30. But what shouldn't be is that it will also output True if neither of the two aspects apply. Does anyone know the solution? Code: # Take steps and minutes as inputs steps = int(input()) active_minutes = int(input()) # Store the result of the operations in the variable goal_achieved = steps > 1000 or active_minutes > 30 # Display the result on the screen print(goal_achieved)
12 Antworten
+ 5
10000 (ten thousand) steps
Not 1000 (one thousand)
If we're looking at the same problem (Python - Fitness Goal challenge)
+ 8
pasos = int(input())
minutos_activos = int(input())
# Almacenar el resultado de las operaciones en la variable
objetivo_alcanzado = pasos > 1000 and minutos_activos > 30
The problem is that you are using operator (or) to verify if one of the two are true, to do this you must use the operator (and) to evaluate the two that must be True.Otherwise, if True is not evaluated, it will result in False.
+ 6
Clara Götz ,
it would have been easier for everyone if a proper task description had been included. additional a reference to the tutorial (name) and the name of the exercise would have been a great help.
+ 4
OMG, that’s It! I just forgot a zero🙈 With the additional zero it works. I had actually already tried the “and” in my time of need. The problem with the task was that the fitness program should return true if one of the two parameters was correct. I didn't explain that here. But thank you very much for the answers. it's very cool to have this community🙂
+ 3
Thank you for your kind words. It's crazy how you can fail so much because of such a stupid mistake. Sometimes you're just blind. I've looked for the error everywhere but there. and if you don't find the error, you slowly come to the brink of madness😂😂😂
+ 3
Hi, absolutely agree. I will do this next time.
+ 3
Clara Götz ,
Python allows gratuitous _ underscores in numeric literals, which can make them easier to read.
1_000
10_000
+ 2
Clara Götz you're already programming just like a professional! 👍🤣 It happens and what meetings are for
+ 2
Thank you Rain,
That’s a very useful tip👍
+ 1
Thnk
0
How to start creating project i don't now how to right code
0
Anish Kamble ,
How to write your own code on Sololearn:
[] Go to Create.
[] Be in the Code tab.
[] Click new (floating circle with + on it).
[] Choose Python (or any language).
[] Land in the playground (editor)
[] Write some code.
[] Run it.
[] Save it.
[] Exit the editor.
[] Land in the Code tab again.
[] Change "Hot Today" to "My Code Bits".
[] See the code you just saved.
[] Later codes get added there too.