not_string

Given a string, return a new string where “not “ has been added to the front. However, if the string already begins with “not”, return the string unchanged. Note: use .equals() to compare 2 strings.

This exercise was taken from codingbat.com and has been adapted for the Python language. There are many great programming exercises there, but the majority are created for Java.

Test 1

Input:

'candy'

Output:

'not candy'

Test 2

Input:

'x'

Output:

'not x'

Test 3

Input:

'not bad'

Output:

'not bad'

Test 4

Input:

'bad'

Output:

'not bad'

Test 5

Input:

'not'

Output:

'not'

Test 6

Input:

'is not'

Output:

'not is not'

Test 7

Input:

'no'

Output:

'not no'