Python Forum
Need help with for loop and variable value substitution in a function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with for loop and variable value substitution in a function
#3
(Jul-21-2020, 05:30 AM)Yoriz Wrote: File tutorials
https://python-forum.io/Thread-Basic-Files
https://docs.python.org/3/tutorial/input...ting-files
for loop tutorials
https://python-forum.io/Thread-for-loops
https://docs.python.org/3/tutorial/contr...statements

I already checked these documents, but it didn't help much on my specific requirement. I am new to Python. I was able to do it with shell scripting, but couldn't find a way around in python.

shell script:

Output:
for i in `cat filename` #here around cat filename i inserted a special symbol that is on the tilde key sitting next to number 1 on the keyboard, it just doesn't get visible here. do ssh -l user@$i done ## Filename contains the list of IP Addresses separated by newline
Reply


Messages In This Thread
RE: Need help with for loop and variable value substitution in a function - by rsurathu - Jul-21-2020, 06:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable for the value element in the index function?? Learner1 8 721 Jan-20-2024, 09:20 PM
Last Post: Learner1
  Variable definitions inside loop / could be better? gugarciap 2 481 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 636 Nov-23-2023, 02:53 PM
Last Post: rob101
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,912 Nov-07-2023, 09:49 AM
Last Post: buran
  Printing the variable from defined function jws 7 1,418 Sep-03-2023, 03:22 PM
Last Post: deanhystad
  Function parameter not writing to variable Karp 5 1,017 Aug-07-2023, 05:58 PM
Last Post: Karp
  Nested for loops - help with iterating a variable outside of the main loop dm222 4 1,664 Aug-17-2022, 10:17 PM
Last Post: deanhystad
  loop (create variable where name is dependent on another variable) brianhclo 1 1,175 Aug-05-2022, 07:46 AM
Last Post: bowlofred
  Retrieve variable from function labgoggles 2 1,077 Jul-01-2022, 07:23 PM
Last Post: labgoggles
  Multiple Loop Statements in a Variable Dexty 1 1,228 May-23-2022, 08:53 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020