DoTracy_assign7_problem4

py

School

New York University *

*We aren’t endorsed by this school

Course

0002-002

Subject

Computer Science

Date

Dec 6, 2023

Type

py

Pages

1

Uploaded by BarristerFlyPerson803

Report
#Tracy Do, Section 009, 11/15/2023, assign 7 problem 4 #Checking if string is the same except one number # function: def differOne # input: two string # processing: use def, for, and if/else statements to create list of conditions to return a string shifted 3 down # output: New string shifted 3 def differOne(w1, w2): # Check if the words have the same length if len(w1) != len(w2): return False # Count the number of differing characters diff_char = 0 # Iterate through each character of the words for i in range(len(w1)): if w1[i] != w2[i]: diff_char += 1 # Return True if only one character differs, otherwise return False return diff_char == 1
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help