wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
class Person {{ int foo; }}; | class Person {{ public: int foo; }}; | Make public. | C++ |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
if (y = 94) {{}} | if (y === 94) {{}} | Use === for equality. | JavaScript |
val foo = 'info' | val foo = "info" | Double quotes. | Kotlin |
h1 {{ font-size:95px color:green; }} | h1 {{ font-size:95px; color:green; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
my @arr = (42,6,42); | my @arr = (42,6,42); | Correct. | Perl |
$list[45] | if ($list.Count -gt 45) {{ $list[45] }} | Check bounds. | PowerShell |
if (bar = 39) {{}} | if (bar == 39) {{}} | Use ==. | Kotlin |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
let str1 = String::from("world"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
x > 24 & y < 31 | x > 24 and y < 31 | Use 'and' not '&'. | Python |
let a = 'world' | let a = "world" | Double quotes. | Swift |
if (c = 24) | if (c == 24) | Use ==. | C++ |
print 'world' | print('world') | print needs parentheses. | Python |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int[] arr = new int[88];
arr[88] = 5; | int[] arr = new int[88];
if (88 < arr.length) arr[88] = 5; | Check bounds. | Java |
String num = 'output'; | String num = "output"; | Double quotes. | Java |
<user><age>hello</age><desc>73</desc></user | <user><age>hello</age><desc>73</desc></user> | Add closing >. | XML |
val temp: Int = 'result' | val temp: String = 'result' | Fix type. | Kotlin |
UPDATE products SET name='hello' WHERE status=10 | UPDATE products SET name='hello' WHERE status=10; | Add semicolon. | SQL |
def foo():
print('info') | def foo():
print('info') | Indent function body. | Python |
foo = 99 | foo=99 | No spaces. | Shell |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
$c = 1; if ($c = 1) {{}} | $c = 1; if ($c == 1) {{}} | Use ==. | PHP |
let c = 16; | let c = 16; | Correct. | JavaScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
const count; | const count = 24; | Initialize const. | JavaScript |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
function compute(): void {{ return 45; }} | function compute(): number {{ return 45; }} | Return type mismatch. | TypeScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (bar = 66) | if (bar == 66) | Use ==. | R |
function baz() {{ echo 'message'; }} | function baz() {{ echo 'message'; }} | Correct. | PHP |
if [ $val = 13 ]; then | if [ "$val" = 13 ]; then | Quote variable. | Shell |
if bar = 3: | if bar == 3: | Use == for comparison. | Python |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
var foo int = 'message' | var foo string = 'message' | Type mismatch. | Go |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
DELETE FROM users WHERE id=69 | DELETE FROM users WHERE id=69; | Add semicolon. | SQL |
let c: number | null = null; c.toFixed(55); | let c: number | null = null; if(c!==null) c.toFixed(55); | Null check. | TypeScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($b = 89) {{}} | if ($b -eq 89) {{}} | Use -eq. | PowerShell |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
for (result in items) | for (result of items) | for...in iterates keys. | JavaScript |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
let x: number = 'output'; | let x: string = 'output'; | Fix type. | TypeScript |
if count = 82 | if count == 82 | Use ==. | Ruby |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
def process
puts 'output'
end | def process
puts 'output'
end | Correct. | Ruby |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
index = world | index = 'world' | Quote strings. | Python |
if x = 66 | if x == 66 | Use ==. | Go |
test | test() | Add parentheses. | Swift |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
disp('hello') | disp('hello') | Correct. | MATLAB |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
jwt.sign({{id:20}}, 'key'); | jwt.sign({{id:20}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
class User {{ int bar; }}
obj.bar=5; | class User {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
if x = 50 {{}} | if x == 50 {{}} | Use ==. | Swift |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
if (bar = 1) {{}} | if (bar == 1) {{}} | Use ==. | Java |
53temp = 10 | temp53 = 10 | Variable cannot start with digit. | Python |
for result in range(52)
print(result) | for result in range(52):
print(result) | Colon after for. | Python |
function process(result:string){{return result;}} process(29); | function process(result:string){{return result;}} process('message'); | Pass correct type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
items[88] | if (items.indices.contains(88)) items[88] | Check index. | Kotlin |
values(74) | if length(values) >= 74, values(74), end | Check length. | MATLAB |
print 'output' | print 'output'; | Add semicolon. | Perl |
x := 85 | x := 85 | Correct. | Go |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
$values[40] = 5; | if (isset($values[40])) $values[40] = 5; | Check existence. | PHP |
{{"name":"hello" "age":39}} | {{"name":"hello", "age":39}} | Add comma. | JSON |
'7' + 38 | 7 + 38 | Avoid string coercion. | JavaScript |
["hello", 76] | ["hello", 76] | Correct. | JSON |
age: value
age: hello, | age: value
age: hello | Remove comma. | YAML |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
let num: i32 = "value"; | let num: &str = "value"; | Type mismatch. | Rust |
bar | bar() | Add parentheses. | Kotlin |
function render() {{
return
{{key:'test'}}
}} | function render() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
int items[23]; items[23]=5; | int items[23]; if(23<23){{}} else items[23]=5; | Bounds check. | C++ |
values.forEach(function(temp) {{ console.log(temp); }}) | values.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
def foo(a):
return a + 1 | def foo(a):
return a + 1 | Correct. | Python |
let mut val=46; let ref1=&mut val; let ref2=&mut val; | let mut val=46; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
for (int i=0; i<79; i++) {{}} | for (int i=0; i<79; i++) {{}} | Correct. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.