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

6th Apr 2021, 10:23 AM
Simisola Osinowo
Simisola Osinowo - avatar
7 ответов
+ 4
password = input() repeat = input() if password == repeat: print("Correct") else: print("Wrong")
6th Apr 2021, 10:36 AM
SAN
SAN - avatar
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
6th Apr 2021, 10:24 AM
Simisola Osinowo
Simisola Osinowo - avatar
0
Thanks
6th Apr 2021, 10:38 AM
Simisola Osinowo
Simisola Osinowo - avatar
0
Thanks
6th Apr 2021, 10:44 AM
Simisola Osinowo
Simisola Osinowo - avatar
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)
6th Apr 2021, 11:05 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Thanks
6th Apr 2021, 11:11 AM
Simisola Osinowo
Simisola Osinowo - avatar
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)
4th Jan 2022, 11:09 PM
Paige Wilcox
Paige Wilcox - avatar