hdanap
March 20th, 2011, 02:59 AM
Hi guys,
1st thing i want to say, this is not an assignment im readn/learning python on my own.
i came across this problem, i really dont understand it, i know how to write doctest when it come to numbers but i really don't know what the book wants me to do, if i could be channeled in the right direction.
Question:
Write Python code to make each of the following doctests pass:
"""
>>> type(fruit)
<type 'str'>
>>> len(fruit)
8
>>> fruit[:3]
'ram'
"""
am i supposed to write a function or just write code in a script?
pls help
my attempt
def word(s):
"""
>>> type(fruit)
<type 'str'>
>>> len(fruit)
8
>>> fruit[:3]
'ram'
"""
fruit='ramadana'
if s == fruit:
x= type(fruit)
y= len(fruit)
z= fruit[:3]
1st thing i want to say, this is not an assignment im readn/learning python on my own.
i came across this problem, i really dont understand it, i know how to write doctest when it come to numbers but i really don't know what the book wants me to do, if i could be channeled in the right direction.
Question:
Write Python code to make each of the following doctests pass:
"""
>>> type(fruit)
<type 'str'>
>>> len(fruit)
8
>>> fruit[:3]
'ram'
"""
am i supposed to write a function or just write code in a script?
pls help
my attempt
def word(s):
"""
>>> type(fruit)
<type 'str'>
>>> len(fruit)
8
>>> fruit[:3]
'ram'
"""
fruit='ramadana'
if s == fruit:
x= type(fruit)
y= len(fruit)
z= fruit[:3]