Question

Python3 create a text file that contains 25 possible passwords read a file and make it...

Python3

create a text file that contains 25 possible passwords

read a file and make it to list of passwords by list comprehension

format the output by creating a function called show_list

Find the password that has same letter twice in a row

Find password contains at least 1 letter

Find password doesn't start with a vowel, but second character is a vowel

find password has twice more not-vowel letters than vowels

password doesn't start with a vowel, but second character is a vowel

0 0
Add a comment Improve this question Transcribed image text
Answer #1

pass_list = [line.strip() for line in open("passwords.txt", "r")]
#get the passwords from txt file

format_output = "{} {} {} {} {}"
def show_list():
print("The Current possibble passwords are:\n","-"*15)


for i in pass_list[25]:

print(format_output.format(pass_list[index]))


print("\nclue 1: password is at least 6 characters long\n")
print("The Current possibble passwords are:\n","-"*15)   
clue1 = [format_output.format(word[0]) for word in pass_list if len(word) >= 6]
print(clue1)

print("\nClue 2: password contains at least 1 letter\n")
print("The Current possibble passwords are:\n","-"*15)
clue2 = [format_output.format(word) for word in clue1 if len([let for let in word if let.isalpha()]) >= 1]
print(clue2)

print("\nClue 3: password doesn't start with a vowel, but second character is a vowel\n\n")
print("The Current possibble passwords are:\n","-"*15)
clue3 = [format_output.format(word) for word in clue2 if tuple(word[0]) != "aeiou" and tuple(word[1]) == "aeiou"]
print(clue3)

print("\nClue 4: password has twice more not-vowel letters than vowels\n")
print("The Current possibble passwords are:\n","-"*15)
clue4 = [format_output.format(word) for word in clue3 if len([let for let in word if let in "qwrtyupsdfghjklzxcvbnm"]) > 2*len([let for let in word if let in "aeiou"])]
print(clue4)

print("\nClue 5 (Bonus): password has same letter twice in a row (password, princess)\n")
print("Password Found!\n","-"*15)
clue5 = [format_output.format(word) for word in clue4 if let[i] == let[i]]
print(clue5)
  
show_list()

Add a comment
Know the answer?
Add Answer to:
Python3 create a text file that contains 25 possible passwords read a file and make it...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a python code named LetterCount with a text file named words.txt that contains at least...

    Create a python code named LetterCount with a text file named words.txt that contains at least 100 words in any format - some words on the same line, some alone (this program involves no writing so you should not be erasing this file). Then create a program in the main.py that prompts the user for a file name then iterates through all the letters in words.txt, counting the frequency of each letter, and then printing those numbers at the end...

  • JAVA Overview Create a method public static void spongeBobify(String inputPath, String outputPath...

    JAVA Overview Create a method public static void spongeBobify(String inputPath, String outputPath, Mode mode) that will convert a file to Mocking Sponge Bob text in 3 different modes. EveryOther capitalize the first letter of the string capitalize every other letter (ignoring non-letter character like punctuation and spaces). non-letter characters don't count toward the every other count Example: mocking sponge bob! → MoCkInG sPoNgE bOb! Vowels capitalize every vowel (not including y) Random capitalize each letter with a probability of 35%....

  • Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin....

    Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin.” The rules used by Pig Latin are as follows: • If a word begins with a vowel, just as "yay" to the end. For example, "out" is translated into "outyay". • If it begins with a consonant, then we take all consonants before...

  • JAVA Code: Complete the program that reads from a text file and counts the occurrence of...

    JAVA Code: Complete the program that reads from a text file and counts the occurrence of each letter of the English alphabet. The given code already opens a specified text file and reads in the text one line at a time to a temporary String. Your task is to go through that String and count the occurrence of the letters and then print out the final tally of each letter (i.e., how many 'a's?, how many 'b's?, etc.) You can...

  • C++ Lab 1. Read in the contents of a text file up to a maximum of...

    C++ Lab 1. Read in the contents of a text file up to a maximum of 1024 words – you create your own input. When reading the file contents, you can discard words that are single characters to avoid symbols, special characters, etc. 2. Sort the words read in ascending order in an array (you are not allowed to use Vectors) using the Selection Sort algorithm implemented in its own function. 3. Search any item input by user in your...

  • [Java] Create a class called FileExercises that contains the following method Method encrypt that does not...

    [Java] Create a class called FileExercises that contains the following method Method encrypt that does not return anything and takes a shift, input filename and output filename as arguments. It should read the input file as a text file and encrypt the content using a Caesar cypher with the shift provided. The resulting text should be placed in the output file specified. (If the output file already exists, replace the existing file with a new file that contains the required...

  • Java question: Create a class called ​Composition​. Read in all of the words in a file...

    Java question: Create a class called ​Composition​. Read in all of the words in a file called dictionary.txt​. Each word will be separated by whitespace (i.e. a space, a tab or a newline character). You must read in all words and determine if a word can be created by concatenating two other words. For example, the word racecar can be created by concatenating race and car. All such possibilities must be output to a file in this format: racecar: race...

  • I am trying to read from a file with with text as follows and I am...

    I am trying to read from a file with with text as follows and I am not sure why my code is not working. DHH-2180 110.25 TOB-6851 -258.45 JNO-1438 375.95 CS 145 Computer Science II IPO-5410 834.15 PWV-5792 793.00 Here is a description of what the class must do: AccountFileIO 1. Create a class called AccountFileIO in the uwstout.cs145.labs.lab02 package. (This is a capital i then a capital o for input/output.) a. This class will read data from a file...

  • Creating Graphs First, write Java code in GraphTest.java to read a data file (graph.in) and create...

    Creating Graphs First, write Java code in GraphTest.java to read a data file (graph.in) and create a graph using the input data. The input file must have the following format: 6 049 0 27 2 3 1 25 2 1 5 6 352 4 5 1 Here, the number on the first line represents the number of vertices in the graph. The letter on the second line indicates whether this is a directed graph ('D') or an undirected graph ('U')....

  • ​ TEXT FILE IS ALREADY GIVEN, JUST NEED TO READ IN THE PROGRAM. Learning objectives: The...

    ​ TEXT FILE IS ALREADY GIVEN, JUST NEED TO READ IN THE PROGRAM. Learning objectives: The intent of this programing project is to allow you the opportunity to demonstrate your ability to solve problems using procedural C++ programming. This project HANG MAN will focus on file I/O and string manipulation in the implementation of the game Hangman. Program Description: In this project, you will write a C++ program that simulates playing the game Hangman. This version of the game will...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT