Stem and Leaf plots

Joined
Oct 13, 2010
Messages
1
Reaction score
0
Hey guys I just recently got into programming, and Python is my first language. I'm trying to get a stem and leaf plot to show by using 3 functions stem_and_leaf(data) This is the function that actually produces the
plot

append_leaf(num) This takes a number (an int) and returns a leaf
(a str), which is the string version of the units digit of the int.

new_stem(num) This takes a number (an int) and returns everythin
but the last character, followed by a space and then a “pipe” (|)
character.

I've completed doing the 2nd two.
def stem_and_leaf(data):
def append_num(num):
append_last=str(num)
print ' ',append_last[-1]

def new_stem(num):
append_first= str(x)
print append_first[:-1], '|'

but when I put it together to print
new_stem(44)+append_num(45)
4 |
5

it adds an enter to the statement and thus make it look like its not a stem and leaf plot. Does anyone know whats going on? and any tips on starting the second half(putting a list through the main function and having a full fledged plot) would be immensly helpful!

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top