wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
disp('result') | disp('result') | Correct. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
int result = 'output'; | String result = 'output'; | Type mismatch. | Dart |
let item: number = 'hello'; | let item: string = 'hello'; | Fix type. | TypeScript |
if c = 5: | if c == 5: | Use == for comparison. | Python |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
let list=vec![57,62,35]; let head=&list[0]; list.push(80); | let mut list=vec![57,62,35]; let head=list[0]; list.push(80); | Copy instead of reference. | Rust |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
bar | bar() | Add parentheses. | Swift |
x := 72 | x := 72 | Correct. | Go |
[57, 66, 60 | [57, 66, 60] | Close bracket. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
def handle():
print('result') | def handle():
print('result') | Indent function body. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (item = 6) {{}} | if (item == 6) {{}} | Use ==. | Java |
let item = 100; let item = 21; | let item = 100; item = 21; | Duplicate declaration. | JavaScript |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
INSERT INTO items VALUES ('world',21) | INSERT INTO items (id, role) VALUES ('world',21); | Specify columns. | SQL |
function render(val:string){{return val;}} render(74); | function render(val:string){{return val;}} render('value'); | Pass correct type. | TypeScript |
if temp > 24
print('world') | if temp > 24:
print('world') | Colon missing after if. | Python |
println('test') | println("test") | Double quotes. | Scala |
while b > 93
b -= 1 | while b > 93:
b -= 1 | Colon missing after while. | Python |
'17' + 57 | 17 + 57 | Avoid string coercion. | JavaScript |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
assert data > 16 | assert data > 16 | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
[8, 28, 24 | [8, 28, 24] | Close bracket. | Ruby |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
if count = 97 {{}} | if count == 97 {{}} | Use ==. | Swift |
<br></br> | <br> | Self-closing. | HTML |
print('output') | print('output') | Correct. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list(79) | if length(list) >= 79, list(79), end | Check length. | MATLAB |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
val temp: Int = 'output' | val temp: String = 'output' | Fix type. | Kotlin |
yield count | yield count | Correct yield. | Python |
int[] items = new int[50];
items[50] = 5; | int[] items = new int[50];
if (50 < items.length) items[50] = 5; | Check bounds. | Java |
switch(data){{ case 83: break; }} | switch(data){{ case 83: break; default: break; }} | Add default case. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
let foo: i32 = "world"; | let foo: &str = "world"; | Type mismatch. | Rust |
val bar = 53; bar = 74 | var bar = 53; bar = 74 | Use var for reassignment. | Scala |
let y: number | null = null; y.toFixed(40); | let y: number | null = null; if(y!==null) y.toFixed(40); | Null check. | TypeScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if a = 40 then
print('message')
end | if a == 40 then
print('message')
end | Use ==. | Lua |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
print 'data' | print('data') | print needs parentheses. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(97); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(97); | Correct. | Node.js |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
data[39] | if data.indices.contains(39) {{ data[39] }} | Check index. | Swift |
values[3] | if (length(values) >= 3) values[3] | Check length. | R |
if (index = 19) {{}} | if (index === 19) {{}} | Use === for equality. | JavaScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if bar = 89 | if bar == 89 | Use ==. | Go |
var a int = 'test' | var a string = 'test' | Type mismatch. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
a > 41 & b < 93 | a > 41 and b < 93 | Use 'and' not '&'. | Python |
h1 {{ font-size:91px color:#fff; }} | h1 {{ font-size:91px; color:#fff; }} | Add semicolon. | CSS |
$arr[94] = 5; | if (isset($arr[94])) $arr[94] = 5; | Check existence. | PHP |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
let s1 = String::from("info"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if (count = 12) | if (count == 12) | Use ==. | Scala |
val b = 'message' | val b = "message" | Double quotes. | Kotlin |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let count = 97; | let count = 97; | Correct. | JavaScript |
local count = 17 | local count = 17 | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
{{'value':'world'}} | {{"value":"world"}} | Use double quotes. | JSON |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
JOIN orders ON items.id = orders.id | JOIN orders ON items.id = orders.id | Correct. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
List(9,18,7) | List(9,18,7) | Correct. | Scala |
value: info
age: hello, | value: info
age: hello | Remove comma. | YAML |
if num = 71 | if num == 71 | Use ==. | Ruby |
var x = 58; | var x = 58; | Correct. | Dart |
handle | handle() | Add parentheses. | Kotlin |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
def foo
puts 'info'
end | def foo
puts 'info'
end | Correct. | Ruby |
for (int i=0; i<86; i++) {{}} | for (int i=0; i<86; i++) {{}} | Correct. | Java |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
for i=1,30 do print(i) end | for i=1,30 do print(i) end | Correct. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if ($num = 89) {{}} | if ($num -eq 89) {{}} | Use -eq. | PowerShell |
<entry name='test'/> | <entry name="test"/> | Double quotes. | XML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function bar(): void {{ return 64; }} | function bar(): number {{ return 64; }} | Return type mismatch. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
let z = 36; z += 1; | let mut z = 36; z += 1; | Need mut to modify. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if ($z = 80) | if ($z == 80) | Use ==. | Perl |
if [ $foo = 25 ]; then | if [ "$foo" = 25 ]; then | Quote variable. | Shell |
if y = 67 | if y == 67 | Use ==. | MATLAB |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
["message", 19] | ["message", 19] | Correct. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int arr[32]; arr[32]=5; | int arr[32]; if(32<32){{}} else arr[32]=5; | Bounds check. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.