i've been having trouble figuring this out since im new to python and i really wanna figure it out!

Write a Sentinel controlled While loop that allows the user to enter text until they enter ! by itself.

Output would be like this:
Enter some text: Hi
Enter some text: ThisIsFun
Enter some text: Bye Now
Enter some text: !
HiThisIsFunBye Now!

Heres what i have to far.

user = 0
total = 0

text =str(input("Enter some text "))

while total != 1:
    total = text + 1
    
    print(total)

What are you using the 'user' variable for? You should use raw_input to set the 'text' variable and if you want it to be called more than once you have to put it inside the while loop.. something like this:

total = 0
text = ''
while text != '!':
   total += 1
   text = raw_input('Enter some text\n')
   print(text)

i was just basing this off an example in a python book i have. thanks for you help.

the code is getting a little closer now, i just dont have any idea what to change. this is the output:

Enter a number 1
Loops Are Neat!
Enter some text
hello
2
Enter some text
Whats up
3
Enter some text
how are you
4
Enter some text
!
5

.... What's the problem? The numbers?

its supposed to not have the numbers, and it stores the text until ! is typed then it prints all of the text.

The code I posted doesn't print numbers, so the code you're using is different

ah i see, yeah im using the newest version of python

def sentinel(s='!'):
    t = inp = raw_input('Enter some text: ')
    while inp != s:
        inp = raw_input('More text: ')
        t += inp
    return t

if __name__ == '__main__':
    print(sentinel())
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.