The words "affect" and "effect" are among the most commonly misused words in the English language. Though both can be used as either a noun or a verb, this doesn't mean they're interchangeable, as the meanings of the words differ. To use them correctly, you must know the definition of each.
Use "effect" as a noun when you mean a change or result or the way something acts upon something else. Consider these examples: "The change in weather was an effect of global warming.Global warming has a detrimental effect on the weather."
Define "affect" as a noun when you work in a medical or social service field. As a noun, the word describes an aspect of behavior, or the way emotion relates to cognitive thinking. For example: "Though the patient is coherent and oriented, his affect is inappropriately flat."
Chose "affect" in most sentences requiring a verb. In this case, the word means to have an influence on or to produce a change. Substitute the word "influence" or "change" to easily test if it makes sense. "We want to see whether driving in the dark affects safety." vs. "We want to see whether driving in the dark influences safety."
Note the subtle difference in the use of "effect" as a verb, which means to cause something to happen or to bring about a result. Substitute the words "bring about" to see if you're using it correctly. For example: "The stimulus checks are designed to effect a better economic status for the country." vs. "The stimulus checks are designed to bring about a better economic status for the country."