Kamba na nyuzi kwenye Python

SohamBhatt

New Member
Joined
Jul 13, 2022
Posts
3
Reaction score
2
Nahitaji kutunga uwezo wa Python ambao unachukua msururu wa kamba kama ugomvi wake. Uwezo unapaswa kuchapisha kamba hizo kwenye muhtasari ambao una kama vifungu vidogo vitu vyote vinavyozingatiwa "feline" au "canine".

Hii ndio nambari ambayo bado sina chochote kinachokuja wakati ninaendesha nambari huko Python:

Code:
def check_string(string_list):
    for word in string_list:
       if "cat" in word or "dog" in word:
    print(word)

Tafadhali pendekeza maoni yako juu ya shida iliyo hapo juu.
Asante mapema
 
Mkuu andika kwa kiingereza tafadhali.
"Kamba", "Ugomvi" na maneno mengine yanachanganya sana.
 
Python:
def check_string(string_list):
    for word in string_list: #second iteration will not work
       if "cat" in word or "dog" in word :
        print(word)

st = "cat,dog,male"

check_string(st) #will not print because there will be no cat or dog in single characters


if "cat" in st :
    print(st) #will print "cat,dog,male"

for word in st :
    print(word) #will print "cat,dog,male" vertically

for word in st :
    if "k" or "f" in word : #second iteration will not work
        print(st)           # #will print "cat,dog,male" 12 times as final results
    else :                  #Also this iteration will not work
        print("No c or o")
Mara 😎 kamba na nyuzi ,hatari kweli kweli, jifunze hapo juu, jaribu kudesign kivingine kwa kutumia dictionary au arrays
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…