×
×
• Create New...

# PY Function - Random Words

## Recommended Posts

Hidden Content

Give reaction to this post to see the hidden content.
( Internal )

Spoiler

Perhaps it will be useful for some people for various systems.

Have fun.

```#	onPressKeyDict[app.DIK_F5]	= lambda : self.Print() # For test function @root/game.py
def Print(self):
import app, chat
list = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" # Set list
maxStr = 10 # Set the maximum number of characters
k = ""

for v in xrange(maxStr): k = k + list[app.GetRandom(0, len(list) - 1)]
chat.AppendChat(chat.CHAT_TYPE_INFO, "Result word: %s" % str(k))```

• 4
• Replies 6
• Created

#### Popular Days

+1

• 1 year later...
• Honorable Member

c++ version

```#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand( time( NULL ) );
char list[] = {"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y"};
int maxStr = 10;
std::string random_word = "";
for (int i = 0; i < maxStr; ++i) {
int randa = rand() % sizeof(list);
if (list[randa] == ',') {
i--;
continue;
}
random_word += list[randa];
}
cout<<random_word;

return 0;
}```

1 godzinę temu, Mali61 napisał:

c++ version

```#include <iostream>
#include <ctime>
using namespace std;
int main()
{
srand( time( NULL ) );
char list[] = {"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y"};
int maxStr = 10;
std::string random_word = "";
for (int i = 0; i < maxStr; ++i) {
int randa = rand() % sizeof(list);
if (list[randa] == ',') {
i--;
continue;
}
random_word += list[randa];
}
cout<<random_word;

return 0;
}```

for what you used comma in table??

• Bot
```import random, string

def Print(maxStr):
list = [x for x in string.digits + string.ascii_letters]
k = ""

for v in range(0, maxStr): k += list[random.randint(0, len(list) - 1)]
print("Result word: %s" % str(k))

Print(10)```

For Python3 + anyone, who wants to use it in an extern program.

Nice idea, not that bad tbh. ^^

King Regards

Cyber

• Honorable Member
24 minutes ago, Nolwarg said:

for what you used comma in table??

For layout, you can delete commas

33 minuty temu, Mali61 napisał:

For layout, you can delete commas

I know lols xD this is better in my opinion:

## Create an account

Register a new account

### Announcements

• -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021

1. 2

2. 2

3. 414

4. 11

5. 9

6. 17

7. 17

8. 2

9. 17