Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list. 10 1789
On Apr 9, 2007, at 3:29 AM, 人言落日是 天涯,望极 天涯不
见家 wrote:
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
import string
list(string.low ercase)
人言落日是 天涯,望极 天涯不见家 schrieb:
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? The range() just can generate the numeric list.
There is:
[ chr(i) for i in range(97, 123) ]
Thomas
On Apr 9, 4:35*pm, Michael Bentley <mich...@jedimi ndworks.comwrot e:
On Apr 9, 2007, at 3:29 AM, 人言落日是 天涯,望极 天涯不
见家 wrote:
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? * The range() just can generate the numeric list.
import string
list(string.low ercase)
Thanks a lot!
On Apr 9, 2:29*am, "人言落日 天涯,望 天涯不见 " <kelvin....@gma il.comwrote:
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? * The range() just can generate the numeric list.
Not very simple, but how about a list comprehension:
import string
lst = [char for char in string.letters[:26] ]
print lst
On Apr 9, 4:39*pm, Thomas Krüger <newsgro...@nos pam.nowire.orgw rote:
人言落日是 天涯,望极 天涯不见家 schrieb:
Is there a simple function to generate a list like ['a', 'b', 'c', ...
'z']? * The range() just can generate the numeric list.
There is:
[ chr(i) for i in range(97, 123) ]
Thomas
Thanks you too! I'm a beginner of python.
map(chr,range(6 5,91))
/Martin
Michael Bentley <mi*****@jedimi ndworks.comwrot e:
>
On Apr 9, 2007, at 3:29 AM, 人言落日是 天涯,望极 天涯不
见家 wrote:
>Is there a simple function to generate a list like ['a', 'b', 'c', ... 'z']? The range() just can generate the numeric list.
import string
list(string.low ercase)
Be careful here. If you change locale that will return all lowercase
letters not just 'a' to 'z'. For example:
>>import locale, string locale.setloc ale(locale.LC_A LL, '')
'English_United Kingdom.1252'
>>print string.lowercas e
abcdefghijklmno pqrstuvwxyz
>>>
On Mon, 09 Apr 2007 01:43:11 -0700, 7stud wrote:
>Is there a simple function to generate a list like ['a', 'b', 'c', ... 'z']? * The range() just can generate the numeric list.
Not very simple, but how about a list comprehension:
import string
lst = [char for char in string.letters[:26] ]
print lst
Anytime you write a list comp like [x for x in thing] that should be a
warning that you shouldn't be writing a list comp.
lst = list(string.let ters[:26])
--
Steven.
Thomas[ chr(i) for i in range(97, 123) ]
Or with fewer magic numbers:
[chr(i) for i in range(ord('a'), ord('z')+1)]
Skip This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: drs |
last post by:
Hi, I am trying to find all lists of length x with elements a, b, and c.
To this end, I have created the class below, but it is not quite working and
I am having trouble figuring out what to change. Does anyone have any
insight?
class c:
def __init__(self):
self.traits = 4 # number of list elements
self.types = 3 # elements can be 0, 1, or 2
|
by: mjcsfo |
last post by:
I can't seem to find a reference nor any helpful threads on this
topic.
I've gotten the following error in two circumstances:
1. A complex type has nested within it another complex type, in the
"Russian doll" style of schema design, where the nested type is
local
and anonymous (not a separate global type).
2. A complex type has nested within it a simple type which is derived
through restriction with at least one facet, again nested,...
|
by: Joseph Barron |
last post by:
Here is a SIMPLE problem that I'm trying to solve.
It works in Netscape 6.2, but IE6 gives ""No such interface
supported."
Below are page1.htm and page2.htm .
In page1.htm, there are two dropdown lists. If you change the
selection of the left one (e.g. choose parentoption2), it
should open up page2.htm in a popup window.
|
by: Michael B Allen |
last post by:
Hi,
I've tried to write the *simplest* memory allocator possible. I think it
would be useful in many cases such as allocating memory on stack as a
poor man's garbage collection perhaps.
I was hoping the clc crowd had some ideas for making it even simpler!
In-lined below the full program (132 lines). It's a circular singular
linked list of "cells" inspired by the one in Plauger's text
|
by: Ross A. Finlayson |
last post by:
I'm trying to write some C code, but I want to use C++'s std::vector.
Indeed, if the code is compiled as C++, I want the container to
actually be std::vector, in this case of a collection of value types or
std::vector<int>.
So where I would use an int* and reallocate it from time to time in C,
and randomly access it via , then I figure to copy the capacity and
reserve methods, because I just need a growable array.
I get to considering...
| |
by: Leon |
last post by:
I have a webform in which when the user press generate button the form
generate six unique ramdon numbers, the user can also type these six numbers
in manually in any order. however, the user can also press a post button
that post these six numbers into the database. My problem is that these six
numbers need to be posted to the database from less to greatest, and all of
my code is within the business tier class not the code behind class.
...
|
by: Claudio Grondi |
last post by:
In the process of learning about some deeper details of Python I am
curious if it is possible to write a 'prefix' code assigning to a and b
something special, so, that Python gets trapped in an endless loop in a
line with:
if a==b: print 'OK'
I mean, it would be of much help to me on my way to understanding Python
to know how such prefix code leading to an endless loop can look like
and if it is eventually not possible to write such...
|
by: Jon Harrop |
last post by:
I am trying to learn C# and .NET programming in general but I am finding it
very hard going. To start with, I'd like to translate some trivial
functions from other languages that I am familiar with into C#.
Here is a simple function in OCaml that nests "n" applications of "f"
around "x", with "n" defaulting to "n=2":
let rec nest ?(n=2) f x = if n=0 then x else nest ~n:(n-1) f (f x)
For example, "nest f x" gives "f(f(x))" and "nest...
|
by: copx |
last post by:
Can anyone point me to a simple, fast RRNG function to generate random ints
within a specified range? It is important that each value within the range
has the same probability (uniform distribution).
I do not want to use the unreliable rand() function, but I do not want to
bloat my code with something as complex as MT either. I am just looking for
a short code snippet that I can copy without worrying about licensing.
The function should...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |