0

Hello, everyone
i just start to learn python, but i have some problem of it
can you help me figure it out please?

my problem is

i want to obtain a sensetce and obtain one randomly words from the use
i want to write a prgram which can find out is the randomly words found in the sensetce or not?

thanks a lot~~

Edited by welcomelambb: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by SgtMe
0

You would want to read the string into an array. Split the string at each space, so you have individual words, and feed it into an array. Then use the "random" module to generate a number from 0 to the length of your array. Then, that integer it gives can be used to read a value from the array at that position. Ie, if it gave you 3, you would write, like:
print array[3]

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.