# File: ChapterStrings/randString.py """ Generate random word. How many letters? 4 rand word is OIOA More(y/n)? y Generate random word. How many letters? 6 rand word is UVVLRT More(y/n)? n Bye """ import random def genString(n): #n = how many letters s = "" for i in range(n): s = s + chr(random.randint(ord('A'),ord('Z'))) #append for strings return s def main(): ans = 'y' #answer while (ans == 'y' or ans == 'Y'): n = int(input("Generate random word. How many letters? ")) word = genString(n) print("rand word is",word) ans = input("More(y/n)? ") print("Bye") # checks if 'Z" is inside print("position of Z:", word.find('Z')) #finds first position of Z main()