Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a question out of Tony Gaddis Getting started with python chapter 9: Question 4, Unique Words The question reads: 'Write a program that

This is a question out of Tony Gaddis Getting started with python chapter 9: Question 4, Unique Words

The question reads:

'Write a program that opesn a specified text file and then displays a list of all the unique words found in the file.'

Hint: Store each word as an element of a set.

Can anybody help me figure out why Im getting this output.

image text in transcribed

image text in transcribed

# Chapter 9: Question 4, Unique Words # Program to display unique words from a text file read file -open ('word. txt', 'r') stread = readfile. read ( ) read file.close word = - - # Assigning it to blank to store a word unique words = set() for character in str read: # Runs a loop for each variable in strread - if character != H: word word + character else: unique words.add (word) word # Assigning blank again to store another word print (unique words)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions