inherit
179688
0
May 16, 2012 10:14:19 GMT -8
dejohnny
3
May 2012
dejohnny
|
Post by dejohnny on May 16, 2012 7:36:15 GMT -8
I'm trying to format Python code correctly using the code tags but, it doesn't work. Python code uses special indentation after the def expression, but as you can see, everything is being pushed to the left (left-justified). Is there another way to do this?
def find_last(searched, target): first_pos = searched.find(target) size = len(searched) print size last_pos =1 while last_pos <= size: #first_pos = searched.find(target) start_char = searched.find(target, first_pos) last_pos = searched.find(target, start_char + 1) last_pos += last_pos print last_pos return last_pos
print find_last('aaaa','a')
|
|
inherit
136163
0
May 9, 2024 7:30:40 GMT -8
ǻñî§ђ™
597
January 2009
anish
|
Post by ǻñî§ђ™ on May 16, 2012 8:28:35 GMT -8
replace the spaces with
|
|
#00AF33
Bark Different.
102833
0
1
Feb 12, 2023 16:57:46 GMT -8
RedBassett
I'm a Marxist/Lennonist of the Groucho/John variety.
15,405
April 2007
applecomputer
RedBassett's Mini-Profile
|
Post by RedBassett on May 16, 2012 9:34:28 GMT -8
Since Python is very specific about the amount of indentation, also be very careful when copying code, and use an editor that will format indents correctly (I have only used emacs for writing python).
|
|
inherit
179688
0
May 16, 2012 10:14:19 GMT -8
dejohnny
3
May 2012
dejohnny
|
Post by dejohnny on May 16, 2012 10:14:19 GMT -8
Thanks a lot for that explanation. I'll use the space markup ( ).
|
|