Python Forum
Error with conditionals
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error with conditionals
#11
I'm sorry. I'm really not seeing what you mean by that. Sorry for the trouble. Could you elaborate? "Whatever it has before it, put that in front of those four lines" That means to put what is before that after the last 4 lines? What?

I´m new to indent terms so i'm not getting it.
Reply
#12
I tested your code and I get
print("28 dias")
when I type 1 and
print("29 dias")
when I type 0. What is the percentage for?
Reply
#13
Percentage means the rest of the division. February has 29 days if n%400 == 0 or n%4 == 0 and n%100 != 0. n = any year you put(1900, 2017)
Reply
#14
Can you provide the full traceback error.
Reply
#15
Traceback (most recent call last):
File "C:\Users\Utilizador\AppData\Local\Programs\Python\Python36-32\mes e dias.py", line 12, in <module>
if n%400 == 0 or n%4 == 0 and n%100 != 0:
NameError: name 'n' is not defined
Is running for every word i only want it to run for february the variable n.
Reply
#16
I'm going to try one more time.

if x > 5:
    if x == 18:
        print('something')
The first line is not indented. The second line is indented once. The third line is indented twice. You need to indent the last four lines one more time each. Indentation is essential to Python. It signifies sections of code that are tied to a particular statement. In this case, the if statements. If you do not understand indentation, you will not be able to program Python.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#17
Got it! Thanks a lot! One question, in this case it needed to be indented one more time to only be atached to the if mes == "Fevreiro"?
Reply
#18
Correct.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Functions with conditionals and comparison operators Drone4four 9 12,763 Jan-01-2019, 06:48 PM
Last Post: Drone4four
  Nested Conditionals Elero 3 7,880 Apr-16-2018, 07:58 PM
Last Post: Elero

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020