0
Trying to solve matching passwords in python core
password = input() repeat = input() def validate(text1, text2): if password == repeat: print("Correct") else: print("Wrong") Don't know what is wrong with my code
7 ответов
+ 4
password = input()
repeat = input()
if password == repeat:
print("Correct")
else:
print("Wrong")
0
You are given a program with two inputs: one as password and the second one as password repeat. Complete and call the given function to output "Correct" if password and repeat are equal, and output "Wrong", if they are not.
Sample Input
nfs1598
nfs1598
Sample Output
Correct
0
Thanks
0
Thanks
0
Referring to your original attempt, there were a number of problems.
1. It appears there is an indentation problem. but that may happened when you posted your attempt.
2. Your def refers directly to your inputs instead of referring to your def ( values)
Remember that defs tend to isolate the code within until called.
3. You never called your def to create an output.
I have attached a working version of your code for reference.
password = input()
repeat = input()
def validate(text1, text2):
if text1 == text2:
print("Correct")
else:
print("Wrong")
validate(password, repeat)
0
Thanks
0
I'm sure this isn't as simple as it COULD be but the lessons aren't terribly clear on this topic. Using an example that wouldn't work didn't help at all. If they would show how things map to each other, that would help so much! Anyway, this felt really brute-forcey but here's what I got while still using a function.
password = str(input())
repeat = str(input())
def wow(password, repeat):
if password == repeat:
print("Correct")
else:
print("Wrong")
wow(password, repeat)