id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

david.white@denison.edu cs111fall2019 > differ
prev  |  next  |  chance

Write a function differ(data1, data2) that returns the first index at which the two lists data1 and data2 differ. If the two lists are the same, your function should return -1. You may assume that the lists have the same length. For example, differ([’CS’, ’rules’, ’!’], [’CS’, ’totally’, ’rules!’]) should return the index 1.


differ([1, 2, 3, 4, 5], [1, 2, 4, 8, 16]) → 2
differ([1, 2, 3, 4, 5], [1, 2, 3, 4, 5]) → -1
differ(['a', 'c', 'b', 'that', 'thing'], ['a', 'that', 'b', 'c', 'thing']) → 1

...Save, Compile, Run (ctrl-enter)

def differ(data1,data2):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Copyright Nick Parlante 2017 - privacy