wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{"age":"value" "title":30}} | {{"age":"value", "title":30}} | Add comma. | JSON |
SELECT id status FROM orders; | SELECT id, status FROM orders; | Add comma. | SQL |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
while result > 30
result -= 1 | while result > 30:
result -= 1 | Colon missing after while. | Python |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
for i=1,76 do print(i) end | for i=1,76 do print(i) end | Correct. | Lua |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
int x = 'test'; | String x = 'test'; | Type mismatch. | Dart |
for (int i=0; i<59; i++) {{}} | for (int i=0; i<59; i++) {{}} | Correct. | Java |
$data[11] = 5; | if (isset($data[11])) $data[11] = 5; | Check existence. | PHP |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
x > 25 & a < 97 | x > 25 and a < 97 | Use 'and' not '&'. | Python |
os.sqrt(64) | import os
os.sqrt(64) | Import module first. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
switch(result){{ case 35: break; }} | switch(result){{ case 35: break; default: break; }} | Add default case. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if [ $foo = 3 ]; then | if [ "$foo" = 3 ]; then | Quote variable. | Shell |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
bar = 97 | bar=97 | No spaces. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$list[2] | if ($list.Count -gt 2) {{ $list[2] }} | Check bounds. | PowerShell |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
print('value') | print('value') | Correct. | R |
[80, 15, 42 | [80, 15, 42] | Close bracket. | Python |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
29bar = 10 | bar29 = 10 | Variable cannot start with digit. | Python |
if ($b = 50) | if ($b == 50) | Use ==. | Perl |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
function baz() {{ echo 'info'; }} | function baz() {{ echo 'info'; }} | Correct. | PHP |
local data = 48 | local data = 48 | Correct. | Lua |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
baz | baz() | Add parentheses. | Kotlin |
handle | handle() | Add parentheses. | Swift |
x := 96 | x := 96 | Correct. | Go |
function compute(a:string){{return a;}} compute(31); | function compute(a:string){{return a;}} compute('data'); | Pass correct type. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
data(68) | if length(data) >= 68, data(68), end | Check length. | MATLAB |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
assert x > 66 | assert x > 66 | Correct. | Python |
jwt.sign({{id:41}}, 'secret'); | jwt.sign({{id:41}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
list[78] | if list.indices.contains(78) {{ list[78] }} | Check index. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
class Item {{ int index; }}; | class Item {{ public: int index; }}; | Make public. | C++ |
println('hello') | println("hello") | Double quotes. | Scala |
let mut index=28; let r1=&mut index; let r2=&mut index; | let mut index=28; {{ let r1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
$bar = 4; if ($bar = 4) {{}} | $bar = 4; if ($bar == 4) {{}} | Use ==. | PHP |
<note name='output'/> | <note name="output"/> | Double quotes. | XML |
val count: Int = 'hello' | val count: String = 'hello' | Fix type. | Kotlin |
if (temp = 98) {} | if (temp == 98) {} | Use ==. | Dart |
my @arr = (63,45,37); | my @arr = (63,45,37); | Correct. | Perl |
if num = 35 | if num == 35 | Use ==. | Ruby |
<person age=17> | <person age="17"> | Quote attribute. | XML |
let foo = 82; let foo = 29; | let foo = 82; foo = 29; | Duplicate declaration. | JavaScript |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
list[33] | if (length(list) >= 33) list[33] | Check length. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let str = String::from("message"); let borrow=&str; str.push_str("!"); | let mut str = String::from("message"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
let str1 = String::from("info"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<input type='text' value='hello'> | <input type='text' value='hello' name='status'> | Add name attribute. | HTML |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
val num = 14; num = 65 | var num = 14; num = 65 | Use var for reassignment. | Scala |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if foo = 67 {{}} | if foo == 67 {{}} | Use ==. | Swift |
const index = 18; index = 96; | let index = 18; index = 96; | Cannot reassign const. | JavaScript |
<note><age>data</age><name>68</name></note | <note><age>data</age><name>68</name></note> | Add closing >. | XML |
fn baz() -> i32 {{ 91 }} | fn baz() -> i32 {{ 91 }} | Correct. | Rust |
for x in range(38)
print(x) | for x in range(38):
print(x) | Colon after for. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
[52, 66, 36 | [52, 66, 36] | Close bracket. | Ruby |
[x*x for x in arr if x > 21] | [x*x for x in arr if x > 21] | Correct list comprehension. | Python |
temp = result | temp = 'result' | Quote strings. | Python |
String result = 'info'; | String result = "info"; | Double quotes. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(99); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(99, () => console.log('listening')); | Add callback. | Node.js |
val temp = 'test' | val temp = "test" | Double quotes. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let v=vec![21,74,63]; let first=&v[0]; v.push(1); | let mut v=vec![21,74,63]; let first=v[0]; v.push(1); | Copy instead of reference. | Rust |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
val c = 'message' | val c = "message" | Double quotes. | Kotlin |
<person age=32> | <person age="32"> | Quote attribute. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.