how to get out of for loop in 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 4 years ago.
Improve this question
I am very new to python programming and started a day ago. I am not getting out of for loop.
for i in range(1,10):
print(i)
print("Hello")
I want to print hello once after coming out of the for loop.

Try this:
for i in range(1,10):
print(i) # This is inside for loop
#LOOP ENDS
print("Hello") # This is out of for-loop
The for-loop ends after print(i) because the next statement, print("Hello") is not indented.

Related

The print statement I use is showing a syntax error, kindly note the error on my code [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
Kindly look at 10th line of this code snippet:
You forgot to close print():
print(txt.read())

my code in code chef is showing NZEC error for this part of code [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
In codechef this part of my code shows error ?
n=int(input())
l=[]
for i in range(n):
l.append(int(input())
You made an error with brackets, there is 1 missing
correct answer:
for i in range(n):
l.append(int(input()))

Codeacademy - SyntaxError: 'return' outside function [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'm not sure why I'm getting this error.enter image description here
You only need a return statement if you are inside a function. The syntax of a function is the following:
def functionName():
# code goes here
return # you can also specify what to return here or just leave it
# blank, a return statement is not necessary.

Problems with print statment [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 am 100% new to programming and I'm having trouble practising the print hello world statement. My code is as follows:
print(hello world!)
You are missing the '' or "" that need to wrap around any string object in Python
Try:
print('Hello World!')
You may find this documentation useful.

Python process thread start and stop timer [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
I'm having problems with my code and I'm not sure why python is not calling my function.
Here is the code I have. I only get Done to print out vice the print statements in startProcess
def startProcess(self):
print("hello")
def repeat(self):
self.startProcess
print("Done")
You are not actually calling self.startProcess, or is it a typo?
Try:
self.startProcess()

Categories

Resources