Red bar after if conditional. (python) [closed] - python

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
In a simple program I was writing in python for experimenting with the language. My program refused to run and said there was a syntax error even though I checked it several times.
I'm currently a beginner at coding so I'm sort of pathetic when it comes to almost everything, including trying to find an answer because most of the jargons are also very new to me.
The error occurred after the if var == 2 and was shown with a red blank bar.
var = 2
if var == 2
print('yes')
else:
print('no')

You are missing a colon after the if statement.

Related

Why is this print function not outputting anything? (very new to python sorry) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I've just started learning python today and downloaded Pycharm, but even the simplest of commands aren't working at all. Could anyone help me with this? Thank you so much.
First use this link to check whether your config is correct. If you are running the correct .py file and it's not printing.
Go to Run>Edit Configurations And select the Emulate Terminal in output console as in the picture below then it should give you output.

Use a line break to print out variables in the same print statement [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I want this same print statement to give me these variables in separate statements:
x = 22.4
y = 23.4
print(y,\n x)
but Python doesn't seem to think it's obvious.
I have tried the r/n and I have also tried printing out my variables with separate print statements, but that is not what I want.
print(f'{y} \n{x}')
This will go good
https://www.geeksforgeeks.org/formatted-string-literals-f-strings-python/
This link will explain how we use f- strings
I recommend you use:
print("{}\n{}".format(x,y))

Invalid syntax python [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I've just started Python,
and everything I was doing was working well until I encountered syntax errors when there were apparently no problems :
def things():
answer = int(input()
if answer == 1:
print("wowie my friend")
and I get invalid syntax on the ":" after the if, I don't know why.
Thanks for helping me
Beware of the parenthesis ! Each open one must be closed. It's a common mistake, but always make sure to check you didn't forgot or put an extra one if you have an InvalidSyntaxError.

Python - if SystaxError [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have problem with this if.
I found I can use in in if-statement.
if "log" in sys.argv[1:]
Syntax Error
If you don't show us the code surrounding the if-statement, we cannot know for sure what the problem is. If I were to make a guess however, I'd say you're missing a colon:
if "log" in sys.argv[1:]:
See the documentation for compound statements (like ifs):
Each clause header begins with a uniquely identifying keyword and ends with a colon

Unknown error in simple code (Python) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I wrote a simple love program in which for every vowel the user scores points that are the outputted at the end. There is an unknown error in the code and I am unable to notice this so if someone could point this out to me I'd be grateful.
awesome=0
name=input("Enter your name, wasteman")
for char in name:
if char in ["a","e","i","o",u"]:
awesome += 1
print("your awesome level is: " + str(awesome))
["a","e","i","o",u"] <- missing opening quote around `u`
It should be:
["a","e","i","o","u"]

Categories