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.
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 7 guests