Display 'word' results on seperate line and print first word of sentences which contain the word (Python)
Date : March 29 2020, 07:55 AM
Hope that helps I am having troubles with this question, could anyone help me out? def find_all(password, File_Path):
password = password.lower()
with open (File_Path, 'r') as o:
for line in o:
if password in line.lower():
print line[:line.find(' ')]
>>> find_all("dark", File_Path)
The
Treasure
Is
In
The
Well
>>>
>>> find_all("lie", File_Path)
Beware
Mister
Black
>>>
|
Print first letter of each word in a line
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I have searched through other posts and have not found an answer that fits my needs. I have a file that is space delimited. I would like to print the first letter of each word in the given line. For example: , One possibility: pax> echo 'This is a test sentence.
This is another.' | sed -e 's/$/ /' -e 's/\([^ ]\)[^ ]* /\1/g' -e 's/^ *//'
Tiats
Tia
|
How to print each letter of a word on its own line using PL/SQL
Date : March 29 2020, 07:55 AM
Hope this helps How to print each letter of a word in a column of a table on its own line using PL/SQL? Word is like this "animal"; I want to convert it like: , Here it is, I just added some codes to yours not to confuse you. DECLARE
x integer; /* you forgot to declare x */
total integer;
schar CHAR; /* variable holding each char of word */
begin
total := length('animal');
x :=1; /* do not miss semicolons */
while x<=total /* in while loop you must use a condition to check for every iteration.*/
LOOP
schar:=substr('animal',x,1);
x:=x+1;
DBMS_OUTPUT.PUT_LINE(schar); /* print the output */
END LOOP;
end;
|
Program accept word as i/p, checks for each single character letter in word consonant/vowel. Condition Print error messa
Tag : java , By : user109127
Date : March 29 2020, 07:55 AM
this will help The issue The problem is in your second for loop, you should not be printing vowel or consonant from within it. This inner loop is just there to decide if the character is a vowel or not, so you should update a boolean inside this loop and print out in the outer loop depending on the value of the boolean. public static void main(String args[]) {
String vowels = "aeiouAEIOU";
char[] vowelsArray = vowels.toCharArray();
Scanner s = new Scanner(System.in);
System.out.println("Enter String");
String inputString = s.next();
char inputStringArray[] = inputString.toCharArray();
if(inputString.matches(".*\\d+.*")) {
System.out.println("WARNING!!!");
System.out.println("please input only string");
} else {
for(int i=0;i<inputStringArray.length;i++) {
// Declare a boolean to say if the character is a Vowel or not
boolean isVowel = false;
// Check the character and set the boolean value
for(int j=0;j<vowelsArray.length;j++) {
if(inputStringArray[i]==vowelsArray[j]) {
isVowel = true;
break;
}
}
// Then do the printing here, in the input characters loop
if(isVowel) {
System.out.print(" VOWEL ");
} else if(inputStringArray[i]!=vowelsArray[i]) {
System.out.print(" consonant ");
}
}
}
if(!inputString.matches("[a-zA-Z]+"))
public static void main(String args[]) {
// declare your vowels
List<Character> vowelsList = Arrays.asList('a', 'e', 'i', 'o', 'u', 'y');
// get the input string
Scanner s = new Scanner(System.in);
System.out.println("Enter String");
String inputString = s.next();
if(!inputString.matches("[a-zA-Z]+")) {
System.out.println("WARNING!!!");
System.out.println("please input only string");
} else {
// Transform your inputString to lower case
// (because we only have lower case in our vowels list)
String lowerCaseInputString = inputString.toLowerCase();
// Then for each character of the input string,
// check if it is in the vowels list or not
for(char c : lowerCaseInputString.toCharArray()) {
if(vowelsList.contains(c)) {
System.out.print(" VOWEL ");
} else {
System.out.print(" consonant ");
}
}
}
}
...
} else {
inputString.toLowerCase().chars()
.mapToObj(c -> vowelsList.contains((char) c) ? " VOWEL " : " consonant ")
.forEach(System.out::print);
}
...
|
How do I print a word on a line, and after every second it prints the word with one extra letter on the end of it every
Date : March 29 2020, 07:55 AM
|