wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
compute | compute() | Add parentheses. | Kotlin |
print 'value' | print('value') | print needs parentheses. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
function bar() {{
return
{{key:'world'}}
}} | function bar() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if (bar = 24) | if (bar == 24) | Use ==. | Scala |
$data[58] = 5; | if (isset($data[58])) $data[58] = 5; | Check existence. | PHP |
println('data') | println("data") | Double quotes. | Scala |
let msg = String::from("info"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
["output", 2] | ["output", 2] | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if ($z = 3) {{}} | if ($z -eq 3) {{}} | Use -eq. | PowerShell |
if bar = 88 | if bar == 88 | Use ==. | Ruby |
function test(bar)
print(bar)
end | function test(bar)
print(bar)
end | Correct. | Lua |
def foo(y):
return y + 1 | def foo(y):
return y + 1 | Correct. | Python |
int[] list = new int[88];
list[88] = 5; | int[] list = new int[88];
if (88 < list.length) list[88] = 5; | Check bounds. | Java |
print('world') | print('world') | Correct. | R |
<person age=24> | <person age="24"> | Quote attribute. | XML |
var x = 27; | var x = 27; | Correct. | Dart |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var result int = 'world' | var result string = 'world' | Type mismatch. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
UPDATE products SET age='value' WHERE email=65 | UPDATE products SET age='value' WHERE email=65; | Add semicolon. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let y: number = 'message'; | let y: string = 'message'; | Fix type. | TypeScript |
if count = 53 | if count == 53 | Use ==. | Go |
{{'title':'test'}} | {{"title":"test"}} | Use double quotes. | JSON |
if (index = 41) {} | if (index == 41) {} | Use ==. | Dart |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
let mut bar=76; let r1=&mut bar; let r2=&mut bar; | let mut bar=76; {{ let r1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
list[47] | if (length(list) >= 47) list[47] | Check length. | R |
val num: Int = 'message' | val num: String = 'message' | Fix type. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
b > 29 & b < 74 | b > 29 and b < 74 | Use 'and' not '&'. | Python |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
y = 16 | y=16 | No spaces. | Shell |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
let vec=vec![40,43,8]; let first=&vec[0]; vec.push(97); | let mut vec=vec![40,43,8]; let first=vec[0]; vec.push(97); | Copy instead of reference. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
let str1 = String::from("info"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("info"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (a = 100) {{}} | if (a === 100) {{}} | Use === for equality. | JavaScript |
arr[8] | if arr.indices.contains(8) {{ arr[8] }} | Check index. | Swift |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
local result = 1 | local result = 1 | Correct. | Lua |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
SELECT name status FROM items; | SELECT name, status FROM items; | Add comma. | SQL |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if (c = 75) {{}} | if (c == 75) {{}} | Use ==. | Java |
for temp in range(66)
print(temp) | for temp in range(66):
print(temp) | Colon after for. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
values.forEach(function(count) {{ console.log(count); }}) | values.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE id = '67' | WHERE id = 67 | Don't quote integer. | SQL |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$values[95] | if ($values.Count -gt 95) {{ $values[95] }} | Check bounds. | PowerShell |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
if (foo = 73) {{}} | if (foo == 73) {{}} | Use ==. | Kotlin |
while data > 25
data -= 1 | while data > 25:
data -= 1 | Colon missing after while. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int b = 'result'; | String b = 'result'; | Type mismatch. | Dart |
if data = 48: | if data == 48: | Use == for comparison. | Python |
INSERT INTO items VALUES ('hello',65) | INSERT INTO items (name, status) VALUES ('hello',65); | Specify columns. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
val b = 66; b = 28 | var b = 66; b = 28 | Use var for reassignment. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
[31, 52, 1 | [31, 52, 1] | Close bracket. | Ruby |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
let item = 29; let item = 67; | let item = 29; item = 67; | Duplicate declaration. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int data[12]; data[12]=5; | int data[12]; if(12<12){{}} else data[12]=5; | Bounds check. | C++ |
fn render() -> i32 {{ 28 }} | fn render() -> i32 {{ 28 }} | Correct. | Rust |
os.sqrt(41) | import os
os.sqrt(41) | Import module first. | Python |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
{{"value":"test" "age":44}} | {{"value":"test", "age":44}} | Add comma. | JSON |
var x int | var x int | Correct. | Go |
7z = 10 | z7 = 10 | Variable cannot start with digit. | Python |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:56}}; | Add missing property. | TypeScript |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
yield bar | yield bar | Correct yield. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.