Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77232 > unrolled thread
| Started by | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| First post | 2014-08-28 16:38 -0400 |
| Last post | 2014-08-28 16:57 -0400 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
When does True == True Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-28 16:38 -0400
Re: When does True == True Andrew Berg <aberg010@my.hennepintech.edu> - 2014-08-28 15:52 -0500
Re: When does True == True Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-28 16:53 -0400
Re: When does True == True Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-28 16:57 -0400
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-28 16:38 -0400 |
| Subject | When does True == True |
| Message-ID | <hf4vv9d552irjamu61rtp1t4hut17c525u@4ax.com> |
import math
import random
import sys
pigword="Razzamattaz"
print ("Pig Latin")
print ("Pick a word containing only alphabetical characters",pigword)
if len(pigword) > 0:
print (pigword)
else:
print ("empty")
if pigword.isalpha() == "True":
print (pigword)
print ("True")
else:
print ("WTF")
print(pigword.isalpha())
What am I doing wrong?
pigword isalpha
the test for true should have passed.
The test for true din't pass even though it prints pigword.isalpha()
True after the else statment.
[toc] | [next] | [standalone]
| From | Andrew Berg <aberg010@my.hennepintech.edu> |
|---|---|
| Date | 2014-08-28 15:52 -0500 |
| Message-ID | <mailman.13579.1409259191.18130.python-list@python.org> |
| In reply to | #77232 |
On 2014.08.28 15:38, Seymore4Head wrote:
> What am I doing wrong?
>>> True == True
True
>>> True == "True"
False
>>> type(True)
<class 'bool'>
>>> type("True")
<class 'str'>
Also, if is already a boolean test, and it is more Pythonic to simply write "if
pigword.isalpha():".
[toc] | [prev] | [next] | [standalone]
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Date | 2014-08-28 16:53 -0400 |
| Message-ID | <0l5vv95fa16vju3geci6kn0pbhsbplll7s@4ax.com> |
| In reply to | #77233 |
On Thu, 28 Aug 2014 15:52:48 -0500, Andrew Berg
<aberg010@my.hennepintech.edu> wrote:
>On 2014.08.28 15:38, Seymore4Head wrote:
>> What am I doing wrong?
>>>> True == True
>True
>>>> True == "True"
>False
>>>> type(True)
><class 'bool'>
>>>> type("True")
><class 'str'>
>
>Also, if is already a boolean test, and it is more Pythonic to simply write "if
>pigword.isalpha():".
I get it.
Thanks
[toc] | [prev] | [next] | [standalone]
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2014-08-28 16:57 -0400 |
| Message-ID | <mailman.13580.1409259464.18130.python-list@python.org> |
| In reply to | #77232 |
[Multipart message — attachments visible in raw view] — view raw
On Aug 28, 2014 4:45 PM, "Seymore4Head" <Seymore4Head@hotmail.invalid>
wrote:
>
> import math
> import random
> import sys
> pigword="Razzamattaz"
> print ("Pig Latin")
> print ("Pick a word containing only alphabetical characters",pigword)
> if len(pigword) > 0:
> print (pigword)
> else:
> print ("empty")
> if pigword.isalpha() == "True":
> print (pigword)
> print ("True")
> else:
> print ("WTF")
> print(pigword.isalpha())
>
> What am I doing wrong?
"True" is not True
>
> pigword isalpha
> the test for true should have passed.
> The test for true din't pass even though it prints pigword.isalpha()
> True after the else statment.
> --
> https://mail.python.org/mailman/listinfo/python-list
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web