Python Forum
Help with university work - reading and writing files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with university work - reading and writing files
#2
Here a hint,there is no need to complitcate the loop just loop over the string.
line = 'The high today will be 15 degrees'
temp = ''
for c in line:
    if c.isdigit():
        temp += c

print(int(temp)) 
Output:
15
Reply


Messages In This Thread
RE: Help with university work - reading and writing files - by snippsat - Nov-01-2022, 05:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Python University Laboratory - Help camibaldessini 2 2,689 Sep-29-2023, 07:56 PM
Last Post: ICanIBB
  [split] University Assignment Help needed Nomathemba 2 6,049 Apr-07-2019, 11:49 PM
Last Post: micseydel
  reading text file and writing to an output file precedded by line numbers kannan 7 13,930 Dec-11-2018, 02:19 PM
Last Post: ichabod801
  University Assignment Help needed Diovanno 3 5,441 Apr-10-2018, 02:46 PM
Last Post: Diovanno

Forum Jump:

User Panel Messages

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