Hello,
I'm working on a program that would print the prefixes of two user inputs if they matched. I'm thinking of this along the lines of if the value of the first character in a is = to the value of the first character in b, print the value. Next I would say that if the value of the first and second characters in a is the same as the first and second characters in b, print items. I didn't get that far before it collapsed. Anyway this is the code I have so far:

>>> first=raw_input("Please enter the first string")
Please enter the first string
>>> second=raw_data("Please enter the second string")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'raw_data' is not defined
>>> second=raw_input("please enter the second string")
please enter the second string
>>> a = first
File "<stdin>", line 1
a = first
^
IndentationError: unexpected indent
>>> a=first
>>> b=second
>>>
>>>
>>> if len(b) < len(a)
File "<stdin>", line 1
if len(b) < len(a)
^
SyntaxError: invalid syntax
>>> if len(b) < len(a):
... a=first
... a=second
... b=first
...
>>> if value 1 in a = value 1 in b
File "<stdin>", line 1
if value 1 in a = value 1 in b
^
SyntaxError: invalid syntax

Use zip function and for loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.