[Tutor] type() problem

2010-08-22 Thread Roelof Wobben

Hello, 

 

This is my exercise:

 

Write Python code to make each of the following doctests pass:


   type(fruit)
  type 'str'
   len(fruit)
  8
   fruit[:3]
  'ram'

I have made this :
   type(fruit)
  type 'str'
   len(fruit)
  8
   fruit[:3]
  'ram'

fruit=ramadana
print fruit heeft als type, type(fruit)
y=len(fruit)
print yz=fruit[:3]
print zEverything works fine except the type () does not give any input.WWhat 
am I doing wrong Roelof ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] type() problem

2010-08-22 Thread Knacktus



fruit=ramadana
print fruit heeft als type, type(fruit)
y=len(fruit)
print y

z=fruit[:3]
print z



These lines put in a module and executed print (using Python 2.7):

fruit heeft als type type 'str'
8
ram

Strange that it doesn't work for you.

I can only advice you to check the file again or run the code from the 
Python shell.


HTH,

Jan


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] type() problem

2010-08-22 Thread Roelof Wobben

Hello, 

 

Very wierd.

From a python shell it works.

If a type it as module in SPE , it doesn't work.

 

Roelof


 
 Date: Sun, 22 Aug 2010 19:47:09 +0200
 From: knack...@googlemail.com
 To: tutor@python.org
 Subject: Re: [Tutor] type() problem
 
 
  fruit=ramadana
  print fruit heeft als type, type(fruit)
  y=len(fruit)
  print y
 
  z=fruit[:3]
  print z
 
 
 These lines put in a module and executed print (using Python 2.7):
 
 fruit heeft als type type 'str'
 8
 ram
 
 Strange that it doesn't work for you.
 
 I can only advice you to check the file again or run the code from the 
 Python shell.
 
 HTH,
 
 Jan
 
 
 ___
 Tutor maillist - Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor
  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor