mardi 2 mai 2017

Double if condition syntax [duplicate]

This question already has an answer here:

I am trying to write a code that checks if two specific words are found in a string. Below I give an example.

if ('dashhkadakdshja' and 'efter') in ' efter parternes ':
    x=1
else:
    x=0
x

I would expect this code to return 0. However, when I run it it returns 1. Can someone explain to me why this is the case ?

What I want it to do: Check if the first string (dashhkadakdshja) is in the given string in the end (efter parternes ) and check if the second string (efter) is in the final string. If both are in there, return a 1. Otherwise, return a 0.

Aucun commentaire:

Enregistrer un commentaire