Last answered:

14 Aug 2020

Posted on:

05 Aug 2020

0

Basic Python Syntax

In the following snippet, I tried the same with int x =100 but I got an error but when I tried the same thing without int it worked. Now I know Python got some features but technically speaking don't you think that my approach was right? x = 100
if x>100 :
print("A busy day")
else:
print("A calm day")
2 answers ( 0 marked as helpful)
Instructor
Posted on:

09 Aug 2020

1
Hi Archisman! Thanks for reaching out. Generally, Python is extremely good at guessing the type of variables you are using.  Should you wish to be specific, you can use the built-in functions, such as int() or float(). Hope this helps.
Best,
Martin
Posted on:

14 Aug 2020

1

Hi Archisman,
You have probably resolved the issue by now. However, I was able to get your code to execute by indenting each print statement as follows.
x = 100
if x > 100:
   print("A busy day")
else:
   print("A calm day")
Python requires the line(s) after the conditional statements must be indented.
I hope this helps.
Anderson

Submit an answer