Simple python code can't execute with invalid syntax [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
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.
Improve this question
The following script is not executable. Did some search and I don't think there is any error.
for i in range(1, length):
itchat.send("జ్ఞా", toUserName=friends[i]['UserName'])
print(f'检测到第{i}位好友: {str(friends[i]["NickName"]).center(20, " ")}')

Try:
for i in range(1, length):
itchat.send("జ్ఞా", toUserName=friends[i]['UserName'])
print('检测到第{}位好友: {}'.format(i, str(friends[i]["NickName"]).center(20, " ")))

Related

my interpreter is showing syntax error for the code given below . can you help debug it? [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
n=int(input())
ls=[]
ls=list(map(int,input().split())
b=0
Here the interpreter is showing a syntax error. How do I tackle this?
c=0
mx=ls[0]
mn=ls[0]
for i in range(1,n):
if ls[i]>mx:
b+=1
mx=ls[i]
if ls[i]<mn:
c+=1
mn=ls[i]
print(b,c)
You are missing a ) at the end of line 3

if statements with and or - not working [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 6 years ago.
Improve this question
I have this code, but for the line "if c=a and d=b+1:", it says SyntaxError: invalid syntax. What is wrong with it?
if c=a and d=b+1:
print("YES")
You need to use == for comparison. = is for assignment to a variable
if c==a and d==b+1:

I am getting error KeyError: 'duration' when it exists [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
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.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
The following code returns error
KeyError: 'duration'
for i in range(0, 3):
exam_df['duration'] = pd.to_datetime(i,(exam_df['Duration '])[i])
exam_df['grade'] = exam_df['Grade'].astype(np.int64)
exam_df.plot.scatter(x='duration', y='grade')
I think that you misspelled the key 'duration', try to change:
exam_df['duration'] = pd.to_datetime(i,(exam_df['Duration '])[i])
With:
exam_df['duration'] = pd.to_datetime(i,(exam_df['duration'])[i])

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"]

Why is this not outputting anything? [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 9 years ago.
Improve this question
Why isn't this giving an output? It is meant to take a sentence as an input and then output the identification of each word.
You never call the function. You do need to run the function to get the output:
print word_identify(words)

Categories