wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
val foo = 16; foo = 37 | var foo = 16; foo = 37 | Use var for reassignment. | Scala |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val item: Int = 'result' | val item: String = 'result' | Fix type. | Kotlin |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
status: message
title: hello, | status: message
title: hello | Remove comma. | YAML |
let foo = 74; | let foo = 74; | Correct. | JavaScript |
let y: i32 = "hello"; | let y: &str = "hello"; | Type mismatch. | Rust |
{{"age":"test" "id":65}} | {{"age":"test", "id":65}} | Add comma. | JSON |
list[76] | if (list.indices.contains(76)) list[76] | Check index. | Kotlin |
let foo = 8; let foo = 6; | let foo = 8; foo = 6; | Duplicate declaration. | JavaScript |
else
print('message') | else:
print('message') | Colon after else. | Python |
if a = 16 {{}} | if a == 16 {{}} | Use ==. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(21); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(21, () => console.log('listening')); | Add callback. | Node.js |
[70, 7, 17 | [70, 7, 17] | Close bracket. | Python |
fn baz() -> i32 {{ 40 }} | fn baz() -> i32 {{ 40 }} | Correct. | Rust |
for (index in items) | for (index of items) | for...in iterates keys. | JavaScript |
DELETE FROM products WHERE name=47 | DELETE FROM products WHERE name=47; | Add semicolon. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
print 'info' | print 'info'; | Add semicolon. | Perl |
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
b = message | b = 'message' | Quote strings. | Python |
while index > 61
index -= 1 | while index > 61:
index -= 1 | Colon missing after while. | Python |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
if num > 24
print('message') | if num > 24:
print('message') | Colon missing after if. | Python |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
if temp > 27
puts 'hello' | if temp > 27
puts 'hello'
end | Add 'end'. | Ruby |
json.sqrt(75) | import json
json.sqrt(75) | Import module first. | Python |
function process(): void {{ return 94; }} | function process(): number {{ return 94; }} | Return type mismatch. | TypeScript |
let data: number = 'result'; | let data: string = 'result'; | Fix type. | TypeScript |
var x int | var x int | Correct. | Go |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
switch(z){{ case 65: break; }} | switch(z){{ case 65: break; default: break; }} | Add default case. | Java |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
values(77) | if length(values) >= 77, values(77), end | Check length. | MATLAB |
if [ $count = 71 ]; then | if [ "$count" = 71 ]; then | Quote variable. | Shell |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
<person><age>output</age><name>89</name></person | <person><age>output</age><name>89</name></person> | Add closing >. | XML |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
int[] values = new int[83];
values[83] = 5; | int[] values = new int[83];
if (83 < values.length) values[83] = 5; | Check bounds. | Java |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(68); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(68); | Correct. | Node.js |
index == '13' | index === 13 | Use strict equality. | JavaScript |
if foo = 65 | if foo == 65 | Use ==. | Ruby |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
data.forEach(function(bar) {{ console.log(bar); }}) | data.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
{{'age':25, 'name' 99}} | {{'age':25, 'name':99}} | Colon missing. | Python |
UPDATE users SET age='data' WHERE email=93 | UPDATE users SET age='data' WHERE email=93; | Add semicolon. | SQL |
if ($item = 64) | if ($item == 64) | Use ==. | Perl |
'2' + 19 | 2 + 19 | Avoid string coercion. | JavaScript |
'world' + 66 | 'world' + 66.to_s | Convert int. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
assert foo > 89 | assert foo > 89 | Correct. | Python |
h1 {{ font-size:59px color:#333; }} | h1 {{ font-size:59px; color:#333; }} | Add semicolon. | CSS |
switch(count){{ case 71: break; }} | switch(count){{ case 71: break; default: break; }} | Add default case. | Java |
UPDATE users SET email='world' WHERE status=71 | UPDATE users SET email='world' WHERE status=71; | Add semicolon. | SQL |
for i=1,33 do print(i) end | for i=1,33 do print(i) end | Correct. | Lua |
def process():
print('output') | def process():
print('output') | Indent function body. | Python |
String val = 'message'; | String val = "message"; | Double quotes. | Java |
for (y in list) | for (y of list) | for...in iterates keys. | JavaScript |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
items[5] | if (length(items) >= 5) items[5] | Check length. | R |
let foo: number = 'output'; | let foo: string = 'output'; | Fix type. | TypeScript |
x := 1 | x := 1 | Correct. | Go |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
var x = 30; | var x = 30; | Correct. | Dart |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
'message' + 96 | 'message' + str(96) | Can't add int to string. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let y: number | null = null; y.toFixed(86); | let y: number | null = null; if(y!==null) y.toFixed(86); | Null check. | TypeScript |
function render(): void {{ return 55; }} | function render(): number {{ return 55; }} | Return type mismatch. | TypeScript |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
baz | baz() | Add parentheses. | Swift |
object Product {{ def main(args: Array[String]) = println("world") }} | object Product {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
my @arr = (40,92,88); | my @arr = (40,92,88); | Correct. | Perl |
let result = 8; result += 1; | let mut result = 8; result += 1; | Need mut to modify. | Rust |
let mut data=75; let r1=&mut data; let r2=&mut data; | let mut data=75; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
if z = 38 | if z == 38 | Use ==. | Go |
function compute() {{ echo 'output'; }} | function compute() {{ echo 'output'; }} | Correct. | PHP |
arr(57) | if length(arr) >= 57, arr(57), end | Check length. | MATLAB |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'value' | print 'value'; | Add semicolon. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if item > 75
puts 'test' | if item > 75
puts 'test'
end | Add 'end'. | Ruby |
function bar(y)
print(y)
end | function bar(y)
print(y)
end | Correct. | Lua |
arr[7] | if arr.indices.contains(7) {{ arr[7] }} | Check index. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
WHERE status = '20' | WHERE status = 20 | Don't quote integer. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.