On 02/06/15 17:25, Stephanie Quiles wrote:
What is the +k+ called? How exactly does it work? I'm a big confused on that...
You seem to be replying to the wrong post.
I assume you mean this one from Joel?
-
>> for k in capitals.keys():
>> state = input('Enter the
On 02/06/15 17:17, Peter Otten wrote:
choice = input('Do you want to play again y/n: ')
if choice.upper() == 'N':
print('end of game')
break
elif choice.upper() != 'Y':
print("invalid choice")
Y goes round again silently.
What is the +k+ called? How exactly does it work? I'm a big confused on
that...
Stephanie Quiles
Sent from my iPhone
> On Jun 2, 2015, at 12:17 PM, Peter Otten <__pete...@web.de> wrote:
>
> Alan Gauld wrote:
>
>>> On 02/06/15 15:15, Peter Otten wrote:
>>>
>>> Not an optimization, but if the
Alan Gauld wrote:
> On 02/06/15 15:15, Peter Otten wrote:
>
>> Not an optimization, but if the user enters neither Y nor N you might ask
>> again instead of assuming Y.
>
> He does. He only breaks if the user enters N
>
>>> choice = input('Do you want to play again y/n: ')
>>>
On 02/06/15 09:45, ZBUDNIEWEK.JAKUB wrote:
I'm a newbie, but was able to tune it to correctly reply to user inputs.
1. My question is can it be optimized in any way?
Code can nearly always be optimised.
Whether it is worth doing so depends on the need to do so.
In this case I douybt its worthwh
On 02/06/15 15:15, Peter Otten wrote:
Not an optimization, but if the user enters neither Y nor N you might ask
again instead of assuming Y.
He does. He only breaks if the user enters N
choice = input('Do you want to play again y/n: ')
if choice.upper() == 'N':
On 02/06/15 15:50, Stephanie Quiles wrote:
> So basically, what I did wrong was the indentation?
Yes.
In Python indentation is all important.
When you write a for (or while) loop Python executes all the
indented code under the opening loop statement. When it sees
an unindented statement it reads
Thank you all for your help! I have a text today but I am not confident with
this. So basically, what I did wrong was the indentation?
Thanks
Stephanie Quiles
Sent from my iPhone
> On Jun 2, 2015, at 10:15 AM, Peter Otten <__pete...@web.de> wrote:
>
> ZBUDNIEWEK. JAKUB wrote:
>
>> I'm a new
ZBUDNIEWEK. JAKUB wrote:
> I'm a newbie, but was able to tune it to correctly reply to user inputs.
> 2. Why (on Windows) do I have to give inputs in quotes not to cause an
> error (for ll input the error is ' NameError: name 'll' is not defined')?
If you are running the script under Python 2 yo
': 'Austin', 'Utah': 'Salt Lake City', \
'Vermont': 'Montpelier', \
'Virginia': 'Richmond', 'Washington': 'Olympia', \
'West Virginia': 'Charleston
On Tue, Jun 2, 2015 at 3:43 AM, Peter Otten <__pete...@web.de> wrote:
> Stephanie Quiles wrote:
>
>> Good evening,
>>
>> As you may have noticed i am really struggling with functions and
>> dictionaries. I need to figure out why this program is allowing me to
>> continue entering incorrect data ins
Stephanie Quiles wrote:
> Good evening,
>
> As you may have noticed i am really struggling with functions and
> dictionaries. I need to figure out why this program is allowing me to
> continue entering incorrect data instead of telling me my answer is
> incorrect. also at the end it’s not tallyin
Good evening,
As you may have noticed i am really struggling with functions and dictionaries.
I need to figure out why this program is allowing me to continue entering
incorrect data instead of telling me my answer is incorrect. also at the end
it’s not tallying the incorrect/correct responses
Mike Nickey wrote:
> What I have is this:
> firstList = ['a', 'b', 'c']
> secondList = [1,2,3]
> thirdList = [1.20, 1.23, 2.54]
>
> What I am looking for is something like this for output:
> {'a': [1, 1.20], 'b': [2, 1.23], 'c': [3, 2.54]}
To get this combine second and third into the list of va
Hi All,
I have a few lists that I'm trying to put into a dictionary based on
which list the user wants to use as a filter. If the user selects 1
the the dictionary would be created using the first list as the keys
and the secondary items as the values. If the user selects 2, the
dictionary would b
Thanks for the detailed explanation Steve. That was very helpful.
On Fri, May 27, 2011 at 8:04 PM, Steven D'Aprano wrote:
> Válas Péter wrote:
>
>> Hi,
>> I think I am new to here, as far as I remember. :-)
>>
>> http://docs.python.org/dev/library/stdtypes.html#dict says:
>> we can create a dicti
2011/5/27 Steven D'Aprano
> Never put a lone dict literal {...} inside a call to dict(), that's just a
> waste of time. Just use the literal on its own.
>
That's what I thought about this, I just didn't want to believe that
docs.python.org wrote a redundant example.
> third_dict = dict(first_di
Válas Péter wrote:
> I think I am new to here, as far as I remember. :-)
>
> http://docs.python.org/dev/library/stdtypes.html#dict says:
> we can create a dictionary with
>
>- dict({'one': 1, 'two': 2})
>
> What is the adventage of this form to simply writing d = {'one': 1, 'two':
> 2}? Is
Nice observation Spawgi.
Sent from my BlackBerry wireless device from MTN
-Original Message-
From: spa...@gmail.com
Sender: tutor-bounces+delegbede=dudupay@python.org
Date: Fri, 27 May 2011 20:01:24
To: Válas Péter
Cc:
Subject: Re: [Tutor] Creating a dictionary
2011. május 27. 16:31 írta, :
> I think the way - d = dict({'one': 1, 'two': 2}) can be used to created
> dictionary using list comprehension.
> e.g.
> >>> d = dict((i,i**2) for i in range(10))
>
> I think this is not the same syntax, there are no braces in. dict({'one':
1, 'two': 2}) rather se
The first instance is more keystrokes while the second saves u that.
Sent from my BlackBerry wireless device from MTN
-Original Message-
From: Válas Péter
Sender: tutor-bounces+delegbede=dudupay@python.org
Date: Fri, 27 May 2011 16:19:08
To:
Cc:
Subject: Re: [Tutor] Creating a
Válas Péter wrote:
Hi,
I think I am new to here, as far as I remember. :-)
http://docs.python.org/dev/library/stdtypes.html#dict says:
we can create a dictionary with
- dict({'one': 1, 'two': 2})
What is the adventage of this form to simply writing d = {'one': 1, 'two': 2}?
Is there any dif
I think the way - d = dict({'one': 1, 'two': 2}) can be used to created
dictionary using list comprehension.
e.g.
>>> d = dict((i,i**2) for i in range(10))
>>> d
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}
I do not think the second approach can be used in this fashion.
>Fr
Sorry, I am afraid, I was not clear enough. So what is the difference
between
d = dict({'one': 1, 'two': 2})
and
d = {'one': 1, 'two': 2}
?
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/m
The first approach does not really give you any variable (in easy form) to
operate upon.
The second approach returns a dict object that you can later reuse in easier
form. So one advantage is certainly that ease of object reuse and also
object modification.
If you want to add, remove, update anythi
Hi,
I think I am new to here, as far as I remember. :-)
http://docs.python.org/dev/library/stdtypes.html#dict says:
we can create a dictionary with
- dict({'one': 1, 'two': 2})
What is the adventage of this form to simply writing d = {'one': 1, 'two': 2}?
Is there any difference?
Thanks
26 matches
Mail list logo