Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 207

Nested commands

$
0
0

One of the skills I am trying to learn is nested commands in Python as I am learning Python being a newbie. As such I have come up with this code. I am not sure what the mistake is. Here is the code:

file = open ("C:\\Users\\text.txt", "r")print(file.read())while True:    content=file.readline()    if not content:        break    return int(content.find(str(i)) for i in range (10))

The output I am getting is "SyntaxError: 'return' outside function". Despite the obvious, I cannot find where my error is. Some help please!

From reading each line of the file to return every number it finds on that line, whether that number is in between the word or standing alone.


Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>