- sent = raw_input()
-
if sent.__contains__("S" or "I" or "H" or "X" or "O" or "N" or "Z"):
-
print("YES")
-
else:
-
print("NO")
This is what I have. If each letter in sent is in that list, print YES else print NO. But as long as i have 1 from the list it prints YES. That is not what I want. How can i fix this?
2 1672 bvdet 2,851
Recognized Expert Moderator Specialist
You will need a loop to do that using the in keyword. - >>> if False in [c in sent for c in letterList]:
-
... print "No"
-
... else:
-
... print "Yes"
-
...
-
No
-
>>>
dwblas 626
Recognized Expert Contributor
You can also use set difference and test for length - control_set=set(["S", "I", "H", "X", "O", "N", "Z"])
-
test_set = set(["B", "S", "I", "H", "X", "O", "N", "Z", "A", "C"])
-
result_set=test_set.difference(control_set)
-
print result_set, len(result_set), "= False"
-
-
test_set = set(["S", "I", "H", "X", "O", "O"])
-
result_set=test_set.difference(control_set)
-
print result_set, len(result_set), "= True"
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mosher |
last post by:
Hi all, I was wondering if php can parse a text string for certain words and
return "true" if that word is found. For example, I have a string like this:
$string = "The rain in spain is the same...
|
by: |
last post by:
If I need to check if a certain value does exist in a field, and return
either "yes" or "not" which query would be the most effestive?
|
by: ief |
last post by:
hi all,
i'm trying to check the length of a numeric value in a string.
this is what i need to do:
I have a string "Mystring (253)"
and a string "SecondString (31548745754)"
Now i have to...
|
by: aboxylica |
last post by:
I have a code in which i create a set of alphabets of specified count .Now in particular positions in it i want to embed my choice of letters how do i do it.here is my code
def random_seq():
...
|
by: JimmyJava694 |
last post by:
Hey everyone,
I need help trying to mutate a String.
For example.. I ask the person to input a number.
Then I ask them to input a String.
(The string they input can be any length, but must...
| |
by: Cylix |
last post by:
Is there any existing method in VB.NET or any 3-third party function
can find out the language in a string?
Let say, isChinese? isFrench?
|
by: TOE022 |
last post by:
Hi!
can anyone help me with this task?
im creating a palindrom :
write a recursic function whitch takes a stringobject(who only contains small letters and numbers) and checks if its a...
|
by: =?Utf-8?B?Sm9hY2hpbQ==?= |
last post by:
Can you make the MaskedTextbox to only allow certain letters e.g.
10:11 A
(Only allow A and P as input)
??
I don't want any other letters than A or P to appear in the text box. I mean
no...
|
by: Shadlan |
last post by:
Hi.
I need to know if a service is running on my server. Is there any PHP
instruction that I can use to do this?
|
by: Gordon |
last post by:
On Oct 23, 9:43 am, Curtis <dye...@gmail.comwrote:
if ($handle = fsockopen ('localhost', 80, $errnum, $errmsg, 1))
{
echo ('A web server is running on this system<br>');
fclose ($handle);
}...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |