How do I change the below code so that it accepts words as answers (currently it only accepts numbers). Thanks in advance :).
for i in range(1,13):
print('What\'s', i, 'x', table, '?')
guess = input()
if guess == 'stop':
break
if guess == 'skip':
print('Skipping question')
continue
ans = i * table
if int(guess)==ans:
print('Correct!)'
else:
print('No, it\'s', ans)
print('Finished')
what language is that ??
for i in range(1,13):
print(‘What’s’, i, ‘x’, table, ‘?’)
guess = input()
if guess == ‘stop’:
break
if guess == ‘skip’:
print(‘Skipping question’)
continue
ans = i * table
if int(guess)==ans:
print(‘Correct!)’
else:
print(‘No, it’s’, ans)
print(‘Finished’)
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
Thanks! Will keep in mind for next time 