- 1
Programm help 😔
Hey I Made a Programm, but it doesn't work 😅. When I Run it and type "Hey whats up and whats the time" It only prints the answer from whats up but Not from whats the time. Pls help :-) https://code.sololearn.com/cOjKdaBhbb1q/?ref=app
11 Réponses
+ 2
Yes I answered that 3 times already.
Here is the code, compare it with yours and find the difference
def user():
global cmd
cmd = input()
eingabe = cmd.lower()
inp = eingabe.split(" ")
for c in inp:
rando = random.randint(1,2)
if c in hallo:
hello = random.randint(1,10)
if hello == 1:
print("Hello!")
elif c == "hey" and hello == 9:
print("Hey, hey!")
elif hello == 1:
print("Hello!")
elif zeit.tm_hour >= 1 and zeit.tm_hour <= 12:
print("Good Morning!")
elif zeit.tm_hour >= 13 and zeit.tm_hour <= 17:
print("Good Afternoon!")
elif zeit.tm_hour >= 18 and zeit.tm_hour <= 22:
print("Good Evening!")
elif zeit.tm_hour >= 23 and zeit.tm_hour <= 24:
print("Good Night!")
if "whats" in inp and "up" in inp:
if rando == 1:
print("Nothing.")
rando = False
if rando == 2:
print("Hmm... I met a man today... It doesn't matter.'")
rando = False
if "help" in inp:
print("You can ask me: \n ")
if "whats" in inp and "time" in inp:
print("It's'", zeit.tm_hour+2,":", zeit.tm_min)
+ 2
Yes ! So that it does not repeat itself for each iteration of the for loop
+ 1
remove your return statements
+ 1
done :)
+ 1
Hint to find the difference : count the number of space before the if "help" and if "whats" lines in your code and mine (and the first "for" line)
0
But then you will display 6 times your answer as the two if "whats" in ... statements are in the for loop and shouldn't be
0
Like this?
0
Nearly
your two last big if, make them go out of the for, so that it does not repeat itself
0
What should I do. No he repeat it 6 times and Not 1
0
The if statements with whats and help is out off the for loop?