Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print line
#11
input is a key word in Python and shouldn't be used. I did the same but then edited my post  Smile

(Jan-18-2017, 07:26 PM)snippsat Wrote: Hmm or.
with open('emails.txt', 'r') as input:    for line in input:        print(line)
so here get email variable overwritten in every loop iteration email = inputfile.readline() What we have at end is just the last line stored in email variable. Maybe easier to see if i do the same in my code:
with open('emails.txt', 'r') as input:    for line in input:        email = line        print(email)
He asked for this. To be stored into a variable.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#12
You are right just,easy to just copy sometime Wink
I fix it too.
Reply
#13
(Jan-18-2017, 07:26 PM)wavic Wrote: He asked for this. To be stored into a variable.
As i mention only last line "emails.txt" will be stored email variable with code we have shown.
That was my point.
Reply
#14
I know that and I knew it during writing my post. But ... Who am I  Big Grin
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#15
Thank you mate !
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with spliting line in print akbarza 3 387 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  Print the line before the corrent line tester_V 9 1,574 Nov-18-2022, 08:39 AM
Last Post: Gribouillis
  Print to a New Line when Appending File DaveG 0 1,222 Mar-30-2022, 04:14 AM
Last Post: DaveG
  If match not found print last line tester_V 2 2,889 Apr-26-2021, 05:18 AM
Last Post: tester_V
  print a line break in writelines() method leodavinci1990 1 6,466 Oct-12-2020, 06:36 AM
Last Post: DeaD_EyE
  Print characters in a single line rather than one at a time hhydration 1 2,033 Oct-10-2020, 10:00 PM
Last Post: bowlofred
  How to print string multiple times on new line ace19887 7 5,755 Sep-30-2020, 02:53 PM
Last Post: buran
  Pattern Require Last Line Print() why? Harshil 4 2,436 Aug-08-2020, 04:54 PM
Last Post: Harshil
  print only last matched line tester_V 24 6,498 Apr-30-2020, 05:16 AM
Last Post: deanhystad
  item from a line to list however when i print the line instead of words i get letters Sutsro 5 2,963 Apr-22-2020, 02:39 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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