-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneraterandomandnonrepeating.py
36 lines (31 loc) · 1.06 KB
/
generaterandomandnonrepeating.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import random
import string
import fileinput
# def randomstring(stringLenght=int(input('enter a length of the string: '))):
# letters=string.ascii_letters
# return ''.join(random.sample(letters,stringLenght))
# print("random String is",randomstring())
# result=randomstring()
# f= open('out.txt','a')
# f.writelines(result)
# f.write('\n')
# f.close()
# stringlength=int(input("Enter a value of string: "))
# # result=randomstring()
# n=int(input("Enter the range to Print: "))
# for i in range(n):
# def randomstring():
# letters=string.ascii_letters
# return ''.join(random.sample(letters,stringlength))
# print(randomstring())
stringlength=int(input("Enter string length: "))
n=int(input("Enter value for Iterations: "))
# for i in range(n):
# letters=string.ascii_letters
# # return ''.join(random.sample(letters,stringlength))
# print(''.join(random.sample(letters,stringlength)))
def randomstring():
for _ in range(n):
letters=string.ascii_letters
print(''.join(random.sample(letters,stringlength)))
randomstring()