Random function

This is the place for queries that don't fit in any of the other categories.

Random function

Postby VictorVt » Fri Jun 28, 2013 4:39 pm

Hello, my first time here, I'm brazilian and I don't write english very well, I aks patiente, please haha

Well, I'm doing a program that it has how input a matriz and a word, and this word will be found and your position print at screen. But we have a problem, we don't know how use the random function this case to make one matrix random as input, someone would know to do?

Do you understand my englsih? I'm trainning, hehe
Posts: 1
Joined: Fri Jun 28, 2013 4:23 pm

Re: Random function

Postby stranac » Fri Jun 28, 2013 4:57 pm

I'm not sure I understood correctly, but you can use random.choice(string.lowercase) to select a random lowercase letter.
You can combine that with a nested loop/listcomp to produce the matrix you want.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
Posts: 1790
Joined: Thu Feb 07, 2013 3:42 pm

Re: Random function

Postby micseydel » Sat Jun 29, 2013 4:34 am

On top of stranac's advice, I would recommend posting your code here. With that extra information, we might be able to figure out what you mean more easily.
Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!

Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from :)
User avatar
Posts: 2904
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Return to General Coding Help

Who is online

Users browsing this forum: snippsat and 6 guests