Hey, everyone. I know how to strip certain characters from a string using for loop. Can you give an example of how that can be done with the use of while loop?
pyprog 0 Light Poster
Recommended Answers
Jump to PostHey, everyone. I know how to strip certain characters from a string using for loop. Can you give an example of how that can be done with the use of while loop?
Please post your code with the for loop and we'll rewrite it with a while loop :)
Jump to PostYou can always replace a for loop by a while loop:
for item in sequence: do_something()
is replaced by
sequence = list(sequence) # <--unnecessary if sequence is a string, tuple or list i = 0 while i < len(sequence): item = sequence[i] do_something() i …
All 6 Replies
lukerobi 4 Junior Poster in Training
Gribouillis 1,391 Programming Explorer Team Colleague
pyprog 0 Light Poster
lukerobi 4 Junior Poster in Training
lukerobi 4 Junior Poster in Training
Gribouillis 1,391 Programming Explorer Team Colleague
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.