Basic python usage, calling a function
<p>I am working on leetcode but actually never wrote a file locally before. </p>

<pre><code>class Solution(object):
    def singleNumber(self, nums):

        for i in range(0,len(nums),2):
            if (i != len(nums) - 1) and (nums[i] != nums[i+1]):
                print (nums[i])
            elif i == len(nums) - 1:
                print (nums[i])

    def main():
        nums=[1,1,2,2,3]
        s=Solution()
        s.singleNumber(nums)
        print('done')
</code></pre>

<p>I am running this script but not seeing any output and don't understand what I'm doing wrong.</p>

<p>Move your <strong>main</strong> function outside of the class, and then specifically execute it:</p>

<pre><code>class Solution(object):
    def singleNumber(self, nums):

        for i in range(0,len(nums),2):
            if (i != len(nums) - 1) and (nums[i] != nums[i+1]):
                print (nums[i])
            elif i == len(nums) - 1:
                print (nums[i])

def main():
    nums=[1,1,2,2,3]
    s=Solution()
    s.singleNumber(nums)
    print('done')

main()
</code></pre>

<p>Output:</p>

<pre><code>3
done
</code></pre>

<p>Another possibility is to make it a separate function at all: drop the <strong>def main</strong> line, un-indent the four lines of that code, and run it from the top level.</p>

python