...
While running:
But the output i expect is :
...
Looks like your variable "j" is being reset in every loop iteration.
If you want it incremented in every iteration, then move it outside the "for" loop - either at the beginning of the function or immediately below the assignment of "res".
I have tried that:
The result is:
It's not coming out from the while loop for each iteration.
Even if i use break also, i am getting the same result.,
But my expected result is :
Thanks
No, you have not. You did move the assignment statement outside the loop, but you also removed the "break" statement.
I did not mention anything about the "break" statement.
Quote:
...
Even if i use break also, i am getting the same result.,
...
Nope, that's not your original program. Go through the program you posted in your first post carefully and ensure that it is identical to the one above, except for the assignment statement i.e. j = 1.
(Hint: check the indentation of each line.)
Quote:
...
Which assignment you want to move outside of for loop?
is already moved before for loop.
Yes I know. That was mentioned in my first post itself.
I have the following code:
#!/usr/bin/env python
mylist =
def printWithoutNewlines():
for objects in mylist:
#print(objects)
objects = objects.replace('hello', "hi")
print objects
When executed, it gives the following output:
## ./loop.py
hi... (3 Replies)
This site is the first to get this snippet.
It will capture an audio recording of any time length within the limits of OSX's QuickTime Player's capablility...
A shell script derivative of this will be used as a further capture for CygWin's AudioScope.sh.
Thoroughly read ALL the comments in... (0 Replies)
Hi all,
I'm looking for secure file encryption tools that use MAC address as encryption key. FYI, I'm using Red Hat Enterprise Linux OS.
For example: when A wants to send file to B
A will encrypt the file with B's computer MAC/IP address as an encryption key
This file can only be decrypted... (2 Replies)
I have the following problem, which I need done in Perl/ or Python using Unix/linux filters...
1. You have a very large file, named 'ColCheckMe', tab-delmited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values... (1 Reply)
I have the following problem, which I need done in Perl/ or Python using Unix/linux filters...
1. You have a very large file, named 'ColCheckMe', tab-delmited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values in the... (1 Reply)
Building software in most languages is a pain. Remember ant build.xml, maven2 pom files, and multi-level makefiles?
Python has a simple solution for building modules, applications, and extensions called distutils. Disutils comes as part of the Python distribution so there are no other packages... (0 Replies)