+ 1
4th Aug 2018, 7:04 PM
Mohamed Sahnoun
Mohamed Sahnoun - avatar
2 odpowiedzi
+ 4
Just a couple of things: First, the if statement would return an error as you're trying to implement a string (any word or sentance) into a math equation, which cannot be done. You would need to convert the variable x into data type integer for it to work (you could do this by just using the int() function - if int(x)...). Second, programming languages generally reserve the = sign for declaring a value for a variable, as you did in the first line. For conditional statements, you would need to use == for it to test the values of both variables within the condition. Additionally, the keywords and function names in Python are case-sensitive, so you would need to type the print function into your code as lowercase (e.g. print()). Lastly, as Python doesn't use curly brackets for any functions or classes, you would need to indent the line just after the if statement for it to be apart of it. This will allow for that one line to run if the if statement returns true.
4th Aug 2018, 7:14 PM
Faisal
Faisal - avatar
+ 1
Thx a lot this was very helpful
4th Aug 2018, 11:40 PM
Mohamed Sahnoun
Mohamed Sahnoun - avatar