New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Text =input()
Word =input()
If word in text:
Print('word found')
Else:
Print('word not found')
+ 3
While ((weight / height) < 18.5):
+ 2
there is space in line three that is giving error but I suggest that use if/elif in the place of while because this code will print infinite loop.
+ 1
There is unnecessary indentation block in line 3 ..and need intended block in line 4 ,6,8,10..I suggest to use if and elif for this code
+ 1
while( (weight / height)<18.5);
+ 1
Use if else statement not while
+ 1
I think the possible errors might be:
1. Indentation error.
2.you should a add a colon(:) after while loop
3. put () around 'weight/height'
0
Where you have written while you should use if, elif or else. Now you have build yourself a loop.
0
How can I fix it
0
height = float(input())
weight = int(input())
if weight/height < 18.5:
print("underweight")
elif weight/height**2 >= 18.5 <25:
print("normal")
elif weight/height**2 >= 25 < 30:
print("overweight")
elif weight/height**2 >= 30:
print("obesity")
0
This also contains error
0
It is better, but you should only indent the lines after if and elif.
Like this:
height = float(input())
weight = int(input())
if weight/height**2 < 18.5:
print("underweight")
0
The error is "Invalid literal for int()"
What should I do
0
The input for weight should be first, then you should ask for heigth.
0
weight = int(input())
height = float(input())
check_bmi = round (weight / (height **2))
if check_bmi < 18.5:
print("Underweight")
elif check_bmi >= 18.5 and check_bmi < 25:
print("Normal")
elif check_bmi >= 25 and check_bmi < 30:
print("Overweight")
elif check_bmi >= 30:
print("Obesity")
0
Now it has error again 😭
0
You’re working on a search engine. Watch your back Google!
The given code takes a text and a word as input and passes them to a function called search().
The search() function should return "Word found" if the word is present in the text, or "Word not found", if it’s not.
Sample Input
"This is awesome"
"awesome"
Sample Output
Word found
0
Could you help me with this
0
Watch your bracket on the while statment