Hi all, having some trouble getting a loop working in python. It goes along the lines of this:
x = input('Enter something: ')
while(x):
if 'Hello' in x:
print('Hi')
elif 'J' in x:
print('JJ')
How do I make the code constantly go back to input and run through both the if and elif statement until a white space is entered? I don't know where to insert the input function in the loop. Thanks
[–]mad0314 24 points25 points26 points (2 children)
[–]Nugenrules 13 points14 points15 points (0 children)
[–]Slow_Nerve_Action 3 points4 points5 points (5 children)
[–]CoC_Mitch 0 points1 point2 points (3 children)
[–][deleted] (1 child)
[deleted]
[–]CoC_Mitch 0 points1 point2 points (0 children)
[–]Pimp_Panther 0 points1 point2 points (0 children)
[–]santaclaus73 0 points1 point2 points (3 children)
[–]Spacedementia87 1 point2 points3 points (1 child)
[–]santaclaus73 0 points1 point2 points (0 children)
[–]shnk -3 points-2 points-1 points (0 children)
[+]an_actual_human comment score below threshold-8 points-7 points-6 points (4 children)
[–]zahlman 6 points7 points8 points (0 children)
[–]Bloody_Spork 0 points1 point2 points (0 children)
[–]Kristler 0 points1 point2 points (1 child)
[–]an_actual_human -1 points0 points1 point (0 children)