def firstAndLast(first,last):
common = []
if first in last:
print first
first = list(raw_input("Enter first name: "))
last = list(raw_input("Enter last name: "))
firstAndLast(first, last)
File "<ipython-input-13-f4ec192dd3a8>", line 11
print names
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(names)?
答案 0 :(得分:2)
您可以setTimeout
:-
import java.util.Scanner;
public class Facebook {
public static void enterPassword() throws Exception {
Scanner sc = new Scanner(System.in);
String password;
System.out.print("Enter your password : ");
password = sc.next();
// sc.close();
if (!password.equals("incorrect")) {
throw new Exception();
}
}
public static void printPassword() {
try {
enterPassword();
} catch (Exception e) {
System.out.println("Your password is incorrect. Try again!");
printPassword();
}
}
public static void enterConfirmationCode() throws Exception {
Scanner sc = new Scanner(System.in);
String fiveDigits;
System.out.print("Enter your 5 digits confirmation code : ");
fiveDigits = sc.next();
// sc.close();
String getDigits = fiveDigits.replaceAll("\\D+", "");
if (getDigits.length() != 5) {
throw new Exception();
}
}
public static void printConfirmationCode() {
try {
enterConfirmationCode();
} catch (Exception e) {
System.out.println("That's too long? Try again!");
printConfirmationCode();
}
}
public static void main(String[] args) {
System.out.println("Welcome to Facebook!");
printPassword();
printConfirmationCode();
System.out.println("Congratulations, you have logged in to Facebook!");
}
}
输出
numpy'sintersect1D
答案 1 :(得分:0)
该错误告诉您该怎么做。 在python-3.x中,print()是带括号的函数,因此您必须在括号中传递参数。
$.ajax({
type: "POST",
url: "/contact",
data: {
myKey1: $("#myKey1").val(),
myKey2: $("#myKey2").val()
},
beforeSend:function(){
$(".loading_msg").hide();
},
complete:function(){
$(".loading_msg").show();
setTimeout(function(){
console.log('Here')
$(".loading_msg").fadeOut("slow");
$("#message").val("")
},3000)
}
});
您也可以只使用print(first)
函数而不是input()
函数
程序
raw_input()
输出
def firstAndLast(first,last):
common = []
for letter in first:
if letter in last:
common.append(letter)
return common
first = input("Enter first name: ")
last = input("Enter last name: ")
common = firstAndLast(first, last)
#common will be the list of common letters
print(common)
答案 2 :(得分:0)
程序:
s1=raw_input("Enter first string:")
s2=raw_input("Enter second string:")
a=list(set(s1)&set(s2))
print("The common letters are:")
for i in a:
print(i)
答案 3 :(得分:0)
s1 = input(“输入第一个字符串:”)
s2 = input(“输入第二个字符串:”)
a = list(set(s1)&set(s2))
print(“常用字母为:”)
对于a中的i:print(i)
答案 4 :(得分:0)
尝试一下
first = list(input("Enter first name: "))
last = list(input("Enter last name: "))
print(f"common characters are: {', '.join(set(first) & set(last))}")
输出:
Enter first name: Jaydip
Enter last name: Kyada
common characters are: a, y, d
我认为这一行会回答您的问题。