Python Forum
I can't for the life of me get this basic If statement code to work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I can't for the life of me get this basic If statement code to work
#2
You normally don't type code like this in python. Normally you write code to a file and pass the filename as an argument to python.

myscript.py
x = 5
if x < 10:
    print("Smaller")  # Must indent + 1 level
if x > 20:    # Must indent -1 level
    print("Bigger")
print("finis")
And you run like this:
Output:
python myscript.py
Reply


Messages In This Thread
RE: I can't for the life of me get this basic If statement code to work - by deanhystad - May-21-2024, 02:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Information Is it possible to multi line a Basic Function Construct line statement? If so how? BrandonKastning 7 525 May-23-2024, 03:02 PM
Last Post: deanhystad
  hi need help to make this code work correctly atulkul1985 5 1,040 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 853 Oct-22-2023, 09:08 PM
Last Post: tronic72
Photo Python code: While loop with if statement HAMOUDA 1 708 Sep-18-2023, 11:18 AM
Last Post: deanhystad
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 856 Sep-05-2023, 12:50 PM
Last Post: ToniE
  Beginner: Code not work when longer list raiviscoding 2 982 May-19-2023, 11:19 AM
Last Post: deanhystad
  code won't advance to next statement MCL169 2 849 Apr-11-2023, 09:44 PM
Last Post: Larz60+
  Why doesn't this code work? What is wrong with path? Melcu54 7 2,130 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  Code used to work 100%, now sometimes works! muzicman0 5 1,669 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  color code doesn't work harryvl 1 1,045 Dec-29-2022, 08:59 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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