I want my program to print the value of the variable 'sob' when I write: write("sob")
Code:
str = input(">")
sob = input(".")
if str == ('write("' + sob + '")'):
print(sob)
else:
print("SYNTAX ERROR")
I want my program to print the value of the variable 'sob' when I write: write("sob")
Code:
str = input(">")
sob = input(".")
if str == ('write("' + sob + '")'):
print(sob)
else:
print("SYNTAX ERROR")
Instead of using input()
use raw_intput()
:
str = raw_input('>')
sob = raw_input(".")
if str == ('write("' + sob + '")'):
print(sob)
else:
print("SYNTAX ERROR")
input()
interprets the input you enter as python commands, whereas raw_input()
returns a string.
Try this
CODE
sob = raw_input('Type write("sob"): ')
sob = sob.lower()
if sob == 'write("sob")':
print(sob.lstrip('Type write("').rstrip('")'))
else:
print("Error")
RESULT
sob