1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
VikaD [51]
4 years ago
6

In this exercise, your function will receive 2 parameters, the name of a text file, and a list of strings. The function will wri

te one line to the text file. The line will contain the fourth character of every string in the list. For any strings that don't have four characters, use x. Be sure to include the newline character at the end.
Computers and Technology
1 answer:
diamong [38]4 years ago
5 0

Answer:

# the function is defined

# it takes 2 arguments: filename and list of string

def solution(filename, listOfString):

   # the file is opened in write mode

   # so that we can write to it

   with open(filename, 'w') as file_object:

       # we loop through the entire list of string

       # this looping help us know what to write to the file

       for each_string in listOfString:

           # if the length of the string is less than 4

           # we write 'x' with a new line

           if len(each_string) < 4:

               file_object.write("x\n")

           # else if the length of the string is greater than equals 4

           # we write the fourth character

           # and also add new line

           else:

               file_object.write(each_string[3])

               file_object.write("\n")

Explanation:

The function is written in Python. It takes two argument; filename and list of string.

It opens the file in write mode and then loop through the list of string. During the loop, we know what to write to the file.

In the length of a string is less than 4; we write 'x' else we write the fourth character in the string. The fourth character has an index of 3 because string uses zero index counting like a string. Starting from zero; 0, 1, 2, 3, 4... the fourth character has an index of 3.

You might be interested in
If you see an icon in a document preset that looks like a tiny web browser window, what type of document is the preset meant to
MatroZZZ [7]

Answer:

I think it's D.

Explanation:

As I think that it is an hyperlink button which links to a word or sentence with a website

6 0
3 years ago
Question #2
stiks02 [169]

Answer:

Step 1: define task

Step 2: process

Step 3: input

Step 4: output

Step 5: check accuracy

Explanation:

Took the test.

4 0
3 years ago
WILL GIVE BRAINLIEST!!! Danielle is warehouse supervisor for a large shipping company. Most shipments need to leave the warehous
VMariaS [17]

Answer:

Punctuality

Explanation:

She needs to get there earlier so that she can see the drivers out on time.

4 0
3 years ago
Hurry answerrrrrrr pleaseee
natka813 [3]

Answer:

bright colors around dull surroundings

Explanation:

4 0
3 years ago
Read 2 more answers
What is diffie-hellman most commonly used for?
Alex777 [14]
DH is an algorithm to derive a shared secret over an unsafe channel.

Both parties exchange public keys, and can join them together with their private keys to create the secret. An eavesdropper can see both public keys, but since he doesn't posess the private keys, cannot derive the same secret.

The secret can be used to subsequently encrypt communications with a symmetric algorithm.

TLS uses this approach.
6 0
3 years ago
Other questions:
  • Users of an extranet can access a company or organization’s entire intranet
    8·2 answers
  • These systems consist of interlinked knowledge resources, databases, human experts, and artificial knowledge agents that collect
    9·1 answer
  • Which is the most common drive letter where Windows stores most data and programs? A. A B. B C. C D. E
    12·2 answers
  • A large lens can be very heavy and can only be supported at the_______.
    13·1 answer
  • One major challenge in developing an international information system is to find​ a(n) ________ when there is so much cultural a
    11·1 answer
  • Which of these is a valid use of the Reply All feature?
    11·1 answer
  • An online bank wants you to create a program that shows prospective customers how their deposits will grow. Your program should
    13·1 answer
  • Why do we use compliment method?
    13·2 answers
  • Which Excel function or tool will you use to display the cells that are referred to by a formula in the selected cell
    8·1 answer
  • Which is not and input device , keyboard , joystick, Monitor, Microphone​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!