-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTexting.py
120 lines (66 loc) · 2.06 KB
/
Texting.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python
# coding: utf-8
# In[34]:
#Some of my friends react via text by saying "asda kjldjsflk;a", with a bunch of random letters. I've always wondered their reaction if I made a longer reaction text; one of a few hundred/thousand letters. Now that's a possiblity :)
#Importing the relevant packages
import string #allows me to import the alphabet
import random #allows me to choose random letters of the alphabet
# In[35]:
#Importing the alphabet, lower-case, upper-case, and combined
alphabet= string.ascii_letters
lower_case_alphabet = string.ascii_lowercase
uppper_case_alphabet = string.ascii_uppercase
print(alphabet)
# In[36]:
#The alphabet is a string
type(alphabet)
# In[37]:
#How many letters do I want following the inital asD
#For the random selection, I'm ensuring that the number (num) is an int
num = int(input("How many letters do you want your message to be? "))
# In[38]:
#confirming the type of the variable, should be int
type(num)
# In[40]:
check = 52
'''
#Allows the user to input another number if they want a shorter string
def checker(num):
while num>check:
x= int(input("Try again, Type a number less than 52! "))
num=x
return num
print("There will be " + str(checker(num)) + " letters in the message")'''
# In[41]:
#function to make the problem work if the inital input is more than 52
if num > 52:
num2 = num/52
num2 = int(num2)
alphabet= alphabet * num2
num3 = num2 *52
else:
num3 = num
# In[42]:
#The beginning of any text
beginning = "asD"
# In[43]:
#Selection of the random letters, num is representating how many letters follow asD
ending=(random.sample(alphabet,num3))
#Below are the random letters selected
print(ending)
# In[44]:
#Changing the list of random numbers to a string
str1 = ""
# traverse in the string
for i in ending:
str1 += i
print(str1)
# In[45]:
#changing the variable to a string, to make it compartible to the beginning
str1 = str(str1)
print(str1)
# In[46]:
#FInal Product
texting = beginning + str1
print(texting)
# In[ ]: