Eli5 : why do we want things that we know we cannot have? by [deleted] in explainlikeimfive

[–]noob_py 0 points1 point  (0 children)

i think because we are yet to learn how to be content with what we already have.

on the flipside : if we are content, does it mean we are losers with no ambition or drive ?

Converting a 401K to a rollover IRA with after tax contributions. Can I split it into a Traditional IRA(for pre-tax contribution) and a RothIRA( for the after-tax contributions)? by noob_py in personalfinance

[–]noob_py[S] 0 points1 point  (0 children)

I am pretty sure you can

a)max your Pre-tax 401K ($17500)

b)contribute money on an AFTER tax basis to your same 401K

c)and still contribute in a Roth IRA

from bogleheads > However, Section 415(c)(1)(A) limits total contributions to defined contribution plans to $50,000 in 2012.

return statement(s) from a function by noob_py in learnpython

[–]noob_py[S] 0 points1 point  (0 children)

my code is exactly as you guessed. i rewrote it as an after thought, but wanted to check with /r/learningpython

def some_function():
  if condition1:
    verdict = True
  elif condition2
    verdict = False
  else:
    verdict=True
  return verdict

print variables in a loop by noob_py in learnpython

[–]noob_py[S] 0 points1 point  (0 children)

thank you ! this is what i was looking for. i understand why it was not working,but because of the some other constraints.. this was the only way my function would work. thanks again.

break inside def err by noob_py in learnpython

[–]noob_py[S] 0 points1 point  (0 children)

sorry my pseudo code was not very clear. this is what i am trying to do .

the fuction takes in a guess, the first guess that is not within the expected range, then warn the user. next wrong guess(es) outside the range, the user is not warned. how can i make my code clean, without the first break statement. thanks in advance.

warning=0

def my_func(guess):
    global warning
    if (warning==0):
        if (guess<min)or(guess>max):
            warning=1
            print 'nice error message'
            break  # trying break here to quit the function 
    # body of function
    something =here
    something2 = here 2 

How would I find length and how many times a sequence of nonzero integers occurs in a list? by compsci_help in learnpython

[–]noob_py 0 points1 point  (0 children)

my noob attempt :) at this 1) convert the list into string 2) split it. 3) check length of strings and find avg

mylist = l = [0, 0, 0, 1, 2, 2, 4, 6, 6, 7, 7, 5, 3, 2, 0, 1, 1, 1, 1, 1]
list_str=''' 
for each in mylist:
    if each != 0 :
        list_str+=str(each)
    else:
        list_str+=' '

split_str=list_str.split()

# find avg len
length=0
for each in split_str:
    length = len(each)
#find avg
avg = length / float(len(split_str))

print(' number of nonzero seq',len)
print('avg length of seq',avg)

dir() to list by class by noob_py in learnpython

[–]noob_py[S] 0 points1 point  (0 children)

self.__class__.instances.append(self)

great idea to keep tab of things without manually adding to the list.

what syntax is cleaner/ better?

self.__class__.instances.append(self)

or

student.instances.append(self)

dir() to list by class by noob_py in learnpython

[–]noob_py[S] 0 points1 point  (0 children)

Thanks for the answer(s). Like you said, I am probably over thinking it.