Random word in a list


#1

If I have this list

KATA_GANTI_1 = [‘saya’,‘Saya’, ‘mereka’, ‘kami’, ‘kita’, ‘aku’, ‘beta’, ‘daku’, ‘engkau’]
KATA_GANTI_2 = [‘anda’ , ‘kamu’, ‘engkau’, ‘kau’, ‘dikau’, ‘mu’ , ‘kalian’ , ‘kamu sekalian’ , ‘sekalian’ ]
SUBJEK = [KATA_GANTI_1 , KATA_GANTI_2, KATA_GANTI_3]

and then the input is : Bulan lalu kamu sudah bilang “Saya mengerjakan sendiri.”

how do I get “kamu” and “saya” and give it another function?


#2

Well, KATA_GANTI_3 does not have a value, so I removed it, and I got this:

KATA_GANTI_1 = ['saya','Saya', 'mereka', 'kami', 'kita', 'aku', 'beta', 'daku', 'engkau']
KATA_GANTI_2 = ['anda' , 'kamu', 'engkau', 'kau', 'dikau', 'mu' , 'kalian' , 'kamu sekalian' , 'sekalian' ]
SUBJEK = [KATA_GANTI_1 , KATA_GANTI_2]
print SUBJEK[0][0] #prints 'saya'
print SUBJEK[1][1] #prints kamu

The value of any listname[a][b] is the bth value of the ath list.
You can change the value of these two by doing:

SUBJEK[0][0] = 'new saya'
SUBJEK[1][1] = 'new kamu'

#3

No, I mean take the word saya and kamu from the input, and give it if-else statement. How do I do that?


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.