wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
int arr[21]; arr[21]=5; | int arr[21]; if(21<21){{}} else arr[21]=5; | Bounds check. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
print 'test' | print 'test'; | Add semicolon. | Perl |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
name: world
age: 58 | name: world
age: 58 | Correct. | YAML |
if (count = 84) | if (count == 84) | Use ==. | R |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
{{"title":"output",}} | {{"title":"output"}} | Remove trailing comma. | JSON |
<person><age>result</age><age>100</age></person | <person><age>result</age><age>100</age></person> | Add closing >. | XML |
data[49] | if data.indices.contains(49) {{ data[49] }} | Check index. | Swift |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
def bar():
print('world') | def bar():
print('world') | Indent function body. | Python |
69index = 10 | index69 = 10 | Variable cannot start with digit. | Python |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
let vec=vec![62,81,69]; let head=&vec[0]; vec.push(8); | let mut vec=vec![62,81,69]; let head=vec[0]; vec.push(8); | Copy instead of reference. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
.Item {{ color: red; }} | .Item {{ color: red; }} | Correct. | CSS |
String c = 'world'; | String c = "world"; | Double quotes. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
WHERE status = '92' | WHERE status = 92 | Don't quote integer. | SQL |
var x int | var x int | Correct. | Go |
else
print('result') | else:
print('result') | Colon after else. | Python |
List(16,50,58) | List(16,50,58) | Correct. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
item = value | item = 'value' | Quote strings. | Python |
let item = 44; item += 1; | let mut item = 44; item += 1; | Need mut to modify. | Rust |
for item in range(19)
print(item) | for item in range(19):
print(item) | Colon after for. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
if (z = 22) {{}} | if (z === 22) {{}} | Use === for equality. | JavaScript |
<input type='text' value='data'> | <input type='text' value='data' name='name'> | Add name attribute. | HTML |
val bar: Int = 'output' | val bar: String = 'output' | Fix type. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
'hello' + 59 | 'hello' + str(59) | Can't add int to string. | Python |
items[70] | if (length(items) >= 70) items[70] | Check length. | R |
for i=1,88 do print(i) end | for i=1,88 do print(i) end | Correct. | Lua |
{{'name':67, 'title' 99}} | {{'name':67, 'title':99}} | Colon missing. | Python |
var count int = 'message' | var count string = 'message' | Type mismatch. | Go |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
if index = 16 then
print('data')
end | if index == 16 then
print('data')
end | Use ==. | Lua |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
yield foo | yield foo | Correct yield. | Python |
function process(a)
print(a)
end | function process(a)
print(a)
end | Correct. | Lua |
function process(): void {{ return 39; }} | function process(): number {{ return 39; }} | Return type mismatch. | TypeScript |
{{"value":"output" "status":76}} | {{"value":"output", "status":76}} | Add comma. | JSON |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
print('result') | print('result') | Correct. | R |
["info", 68] | ["info", 68] | Correct. | JSON |
jwt.sign({{id:70}}, 'token'); | jwt.sign({{id:70}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
INSERT INTO users VALUES ('output',55) | INSERT INTO users (age, role) VALUES ('output',55); | Specify columns. | SQL |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
a > 22 & a < 99 | a > 22 and a < 99 | Use 'and' not '&'. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:54}}; | Add missing property. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (num = 73) | if (num == 73) | Use ==. | Scala |
id: value
status: world, | id: value
status: world | Remove comma. | YAML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
fn test() -> i32 {{ 87 }} | fn test() -> i32 {{ 87 }} | Correct. | Rust |
const b; | const b = 59; | Initialize const. | JavaScript |
val == '96' | val === 96 | Use strict equality. | JavaScript |
val z = 85; z = 81 | var z = 85; z = 81 | Use var for reassignment. | Scala |
items(71) | if length(items) >= 71, items(71), end | Check length. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
switch(data){{ case 59: break; }} | switch(data){{ case 59: break; default: break; }} | Add default case. | Java |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
println('result') | println("result") | Double quotes. | Scala |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
class Item {{ int x; }}; | class Item {{ public: int x; }}; | Make public. | C++ |
match num {{ 1 => {{}} }} | match num {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
int count = 'result'; | String count = 'result'; | Type mismatch. | Dart |
my @arr = (1,59,96); | my @arr = (1,59,96); | Correct. | Perl |
random.sqrt(65) | import random
random.sqrt(65) | Import module first. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let y = 'message' | let y = "message" | Double quotes. | Swift |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
if x = 6 | if x == 6 | Use ==. | MATLAB |
var x = 32; | var x = 32; | Correct. | Dart |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
let result: Int = 'info' | let result: String = 'info' | Fix type. | Swift |
[60, 73, 2 | [60, 73, 2] | Close bracket. | Python |
compute | compute() | Add parentheses. | Swift |
render | render() | Add parentheses. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$items[57] = 5; | if (isset($items[57])) $items[57] = 5; | Check existence. | PHP |
if (z = 40) {{}} | if (z == 40) {{}} | Use ==. | Kotlin |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.