Basics of Python,learning

G

Guido van Brakel

Hello

Why is this not working,and how can I correct it?
#!/usr/bin/env python
#coding=utf-8

z = raw_input ('Give numbers')
y = z.split()
b=[]

for i in y:
b.append(float(i))

def b(min,max,gem)
x=min(a)
x=gem(a)
x=max(a)
return a

print min(a)
print max(a)
print gem(a)



Regards,
 
M

Mensanator

Hello

Why is this not working,

Why is _what_ not working?
and how can I correct it?

Start over.
#!/usr/bin/env python
#coding=utf-8
z = raw_input ('Give numbers')
y = z.split()
b=[]
for i in y:
     b.append(float(i))
def b(min,max,gem)
    x=min(a)
    x=gem(a)
    x=max(a)
    return a
print min(a)
print max(a)
print gem(a)

Regards,

--
Guido van Brakel
Life is like a box of chocolates, you never know what you're gonna get
--- Hide quoted text -

- Show quoted text -
 
D

D'Arcy J.M. Cain

Hello

Why is this not working,and how can I correct it?

What are you expecting it to do? For one thing, you are acting on a
variable 'a' but it is never defined. The only objects that you have
is z, y, b and then b is redefined as a method which creates a variable
'x', overwrites it twice and then discards it. Doesn't matter since
you never call the method anyway.

Back to the textbook I think.
 
G

Gabriel Genellina

En Sun, 16 Mar 2008 14:25:26 -0200, Guido van Brakel
Why is this not working,and how can I correct it?

I guess you want to:
a) read a single line containing many numbers separated by white space
b) convert them to a list of floating point numbers
c) print their minimum and maximum value

a) Already done
b) Already done
y = z.split()
b=[]
for i in y:
b.append(float(i))

The list of numbers is called "b". Don't define a function with the same
name, you'll lose the original list attached to the name "b".

c) Almost done; remember that your list of numbers is called "b" not "a":

d) We (Python and me) have no idea what "gem" is:
 

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

Similar Threads


Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top