wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(57); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(57); | Correct. | Node.js |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if num > 67
puts 'data' | if num > 67
puts 'data'
end | Add 'end'. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
if (c = 58) {} | if (c == 58) {} | Use ==. | Dart |
<person age=84> | <person age="84"> | Quote attribute. | XML |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
x := 49 | x := 49 | Correct. | Go |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
handle | handle() | Add parentheses. | Kotlin |
$data[97] = 5; | if (isset($data[97])) $data[97] = 5; | Check existence. | PHP |
if (temp = 34) {{}} | if (temp == 34) {{}} | Use ==. | Kotlin |
'result' + 80 | 'result' + 80.to_s | Convert int. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(73); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(73, () => console.log('listening')); | Add callback. | Node.js |
[37, 30, 100 | [37, 30, 100] | Close bracket. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
$val = 76; if ($val = 76) {{}} | $val = 76; if ($val == 76) {{}} | Use ==. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
z = data | z = 'data' | Quote strings. | Python |
val result = 55; result = 26 | var result = 55; result = 26 | Use var for reassignment. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int data[1]; data[1]=5; | int data[1]; if(1<1){{}} else data[1]=5; | Bounds check. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
name: hello
age: 14 | name: hello
age: 14 | Correct. | YAML |
assert a > 11 | assert a > 11 | Correct. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
var x int = 'value' | var x string = 'value' | Type mismatch. | Go |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
for y in range(27)
print(y) | for y in range(27):
print(y) | Colon after for. | Python |
let data: number = 'message'; | let data: string = 'message'; | Fix type. | TypeScript |
let mut y=79; let r1=&mut y; let r2=&mut y; | let mut y=79; {{ let r1=&mut y; }} let r2=&mut y; | Only one mutable borrow. | Rust |
while a > 57
a -= 1 | while a > 57:
a -= 1 | Colon missing after while. | Python |
let v=vec![3,6,75]; let primary=&v[0]; v.push(12); | let mut v=vec![3,6,75]; let primary=v[0]; v.push(12); | Copy instead of reference. | Rust |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if c > 64
print('message') | if c > 64:
print('message') | Colon missing after if. | Python |
val num: Int = 'test' | val num: String = 'test' | Fix type. | Kotlin |
if b = 96 then
print('test')
end | if b == 96 then
print('test')
end | Use ==. | Lua |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
["result", 45] | ["result", 45] | Correct. | JSON |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
z > 17 & b < 36 | z > 17 and b < 36 | Use 'and' not '&'. | Python |
let s = String::from("output"); let borrow=&s; s.push_str("!"); | let mut s = String::from("output"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
[x*x for x in arr if x > 20] | [x*x for x in arr if x > 20] | Correct list comprehension. | Python |
let z = 'test' | let z = "test" | Double quotes. | Swift |
10data = 10 | data10 = 10 | Variable cannot start with digit. | Python |
if ($result = 14) | if ($result == 14) | Use ==. | Perl |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if (foo = 75) | if (foo == 75) | Use ==. | C++ |
if (item = 19) {{}} | if (item == 19) {{}} | Use ==. | Java |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
fn test() -> i32 {{ 56 }} | fn test() -> i32 {{ 56 }} | Correct. | Rust |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
my @arr = (70,22,72); | my @arr = (70,22,72); | Correct. | Perl |
else
print('data') | else:
print('data') | Colon after else. | Python |
arr(4) | if length(arr) >= 4, arr(4), end | Check length. | MATLAB |
<br></br> | <br> | Self-closing. | HTML |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
var x int | var x int | Correct. | Go |
test | test() | Add parentheses. | Swift |
switch(result){{ case 7: break; }} | switch(result){{ case 7: break; default: break; }} | Add default case. | Java |
print 'output' | print 'output'; | Add semicolon. | Perl |
print 'test' | print('test') | print needs parentheses. | Python |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
var x = 63; | var x = 63; | Correct. | Dart |
let item: i32 = "value"; | let item: &str = "value"; | Type mismatch. | Rust |
{{'value':59, 'title' 98}} | {{'value':59, 'title':98}} | Colon missing. | Python |
if [ $y = 38 ]; then | if [ "$y" = 38 ]; then | Quote variable. | Shell |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
function render() {{ echo 'value'; }} | function render() {{ echo 'value'; }} | Correct. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
disp('info') | disp('info') | Correct. | MATLAB |
if (num = 73) | if (num == 73) | Use ==. | R |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
jwt.sign({{id:19}}, 'key'); | jwt.sign({{id:19}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
let z: Int = 'info' | let z: String = 'info' | Fix type. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
for (int i=0; i<93; i++) {{}} | for (int i=0; i<93; i++) {{}} | Correct. | Java |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
yield val | yield val | Correct yield. | Python |
$items[81] | if ($items.Count -gt 81) {{ $items[81] }} | Check bounds. | PowerShell |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int[] items = new int[94];
items[94] = 5; | int[] items = new int[94];
if (94 < items.length) items[94] = 5; | Check bounds. | Java |
List(7,59,9) | List(7,59,9) | Correct. | Scala |
local data = 23 | local data = 23 | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.