I am new to python (coming from R) and trying to practice for loops, so I made up this challenge to have the computer guess the name string. Unfortunately I have stumped myself. Can anyone offer assistance?
## Guess a name
name = 'Kate'
char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRZTUVWXYZ'
for k in range(len(name)):
for i in range(len(char)):
if name[k] == char[i]:
print('Your name is ' + char[i])
This gives the following output:
Your name is K
Your name is a
Your name is t
Your name is e
But I am looking for:
Your name is Kate