Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41156

A string and an integer to appear in tuple (python 2.7)

Newsgroups comp.lang.python
Date 2013-03-12 17:21 -0700
Message-ID <36706e17-0a2d-46eb-b222-09b90ec6ab58@googlegroups.com> (permalink)
Subject A string and an integer to appear in tuple (python 2.7)
From Jiewei Huang <jiewei24@gmail.com>

Show all headers | View raw


Hi all,

I'm currently stuck at this question on 

Writing a function len_str that takes a string as an argument and returns a pair consisting of the length of the string and the string itself. 

Example: len_str('Meaning of life') should return the tuple (15, 'Meaning of life').


I can only think of this :

len_str = ('welcome to life' )

print (len(len_str,), len_str)


However that not an correct answer I need to make a def len_str but I can't seen to get it right.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

A string and an integer to appear in tuple (python 2.7) Jiewei Huang <jiewei24@gmail.com> - 2013-03-12 17:21 -0700
  Re: A string and an integer to appear in tuple (python 2.7) Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-03-13 00:43 +0000
  Re: A string and an integer to appear in tuple (python 2.7) Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-03-13 02:06 +0100

csiph-web