[Tutor] Fwd: Sys.argv read parameters
Danny Yoo
dyoo at hashcollision.org
Wed Apr 17 23:45:16 CEST 2013
Forwarding message to Python-tutor mailing list. I did not realize
that your reply didn't show up for the rest of Python tutor. Please
use Reply to All in the future.
---------- Forwarded message ----------
From: Danilo Chilene <bicofino at gmail.com>
Date: Wed, Apr 17, 2013 at 2:17 PM
Subject: Re: [Tutor] Sys.argv read parameters
To: Danny Yoo <dyoo at hashcollision.org>
Hello Danny,
The part that is changing is just the sys.argv[1]
The vars will have always the same content.
What I don't want is to have like 255 'ifs' if I have 255 vars.
On Wed, Apr 17, 2013 at 5:03 PM, Danny Yoo <dyoo at hashcollision.org> wrote:
>
> What's the part that's "changing"? What's the part that stays the same?
>
> I would recommend thinking of this in terms of a function.
>
> Can you write a function that consumes a letter l and returns the
> string "This is ..." where "..." is the uppercased l?
>
> As an example of a simple function on strings:
>
> ##########################
> ## double: string -> string
> def double(x):
> return x + x
>
> ## For example, a blast from the past:
> print "The Noid says: " + double("pizza")
> ##########################
>
>
> There are functions in Python standard library that know how to do
> things to strings. See:
>
> http://docs.python.org/2/library/stdtypes.html#string-methods
More information about the Tutor
mailing list