|
i'm trying to learn python and i'm still very babbyish. i did something like thiscode:
when i print out the records in my array, everything in the model subclass returns the output "<bound method model.name of <__main__.model at blah blah memory address" i get that it's returning the metadata about the attribute i want instead of the value of that attribute because it's not inheriting correctly, but i'm having a hard time figuring out exactly how i'm making this mistake also please feel free to point out any other mistakes and bad conventions i'm doing here, i just started learning how to code
|
# ¿ Dec 16, 2014 06:36 |
|
|
# ¿ May 19, 2024 22:39 |
|
i'm trying to make a palindrome tester, what am i doing wrong here?code:
i managed to get it to work much more cleanly with a for code:
|
# ¿ Oct 13, 2015 08:08 |
|
Xeno54 posted:The "return True" is over indented and inside the while loop, so your code will either return True or False on the first iteration (see Hammerite's analysis). You should be good if you remove an indent and have "return True" at the same level as the while loop. i thought i tried that, huh. so if i do that, then 'while the counter is whatever if comparison is still valid deincrement searchLength and try again' is the expected behavior? e: haha, that was the correct placement of the return in my previous test, but i forgot to test for str[index] == str[index-1]], and one of my test words was 'banana', which is a valid offset palindrome under that logic... boner confessor fucked around with this message at 15:57 on Oct 13, 2015 |
# ¿ Oct 13, 2015 15:47 |
|
both of these just flip the string and test that against the input, right? i figured that was more efficient but i wanted to do a step by step comparisonSurgicalOntologist posted:
return is a built in function that produces a bool '' creates a new empty string? .join fills in the new string with the reversed input x == x tests to see if this new string is the same as the input string Python code:
thanks all
|
# ¿ Oct 15, 2015 06:28 |