Загрузить файлы в «/»
This commit is contained in:
		
							parent
							
								
									5e7244619b
								
							
						
					
					
						commit
						bb281e2f1a
					
				
							
								
								
									
										21
									
								
								script.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								script.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
with open("data.txt", "r", encoding="utf-8") as file:
 | 
			
		||||
    lines = file.readlines()
 | 
			
		||||
 | 
			
		||||
numbers = []
 | 
			
		||||
words = []
 | 
			
		||||
for line in lines:
 | 
			
		||||
    line = line.strip()  
 | 
			
		||||
    if line.isdigit():
 | 
			
		||||
        numbers.append(line)
 | 
			
		||||
    else:
 | 
			
		||||
        words.append(line)
 | 
			
		||||
with open("output.txt", "w", encoding="utf-8") as output_file:
 | 
			
		||||
    output_file.write("Слова:\n")
 | 
			
		||||
    for word in words:
 | 
			
		||||
        output_file.write(word + "\n")
 | 
			
		||||
    
 | 
			
		||||
    output_file.write("\nЧисла:\n")
 | 
			
		||||
    for number in numbers:
 | 
			
		||||
        output_file.write(number + "\n")
 | 
			
		||||
 | 
			
		||||
print("Файл output.txt успешно создан!")
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user