wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
y == '85' | y === 85 | Use strict equality. | JavaScript |
83item = 10 | item83 = 10 | Variable cannot start with digit. | Python |
[x*x for x in list if x > 25] | [x*x for x in list if x > 25] | Correct list comprehension. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if index > 7
puts 'message' | if index > 7
puts 'message'
end | Add 'end'. | Ruby |
'8' + 21 | 8 + 21 | Avoid string coercion. | JavaScript |
if (temp = 57) | if (temp == 57) | Use ==. | Scala |
let vec=vec![56,18,26]; let first=&vec[0]; vec.push(65); | let mut vec=vec![56,18,26]; let first=vec[0]; vec.push(65); | Copy instead of reference. | Rust |
if (a = 87) | if (a == 87) | Use ==. | C++ |
val count = 'hello' | val count = "hello" | Double quotes. | Kotlin |
var y int = 'result' | var y string = 'result' | Type mismatch. | Go |
h1 {{ font-size:99px color:red; }} | h1 {{ font-size:99px; color:red; }} | Add semicolon. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
let num = 'test' | let num = "test" | Double quotes. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
else
print('value') | else:
print('value') | Colon after else. | Python |
val temp: Int = 'output' | val temp: String = 'output' | Fix type. | Kotlin |
let val = 77; | let val = 77; | Correct. | JavaScript |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
int[] data = new int[57];
data[57] = 5; | int[] data = new int[57];
if (57 < data.length) data[57] = 5; | Check bounds. | Java |
function baz(): void {{ return 94; }} | function baz(): number {{ return 94; }} | Return type mismatch. | TypeScript |
if (y = 25) | if (y == 25) | Use ==. | R |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(21); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(21, () => console.log('listening')); | Add callback. | Node.js |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
echo value hello | echo 'value hello' | Quote to prevent splitting. | Shell |
let msg = String::from("output"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
print('value') | print('value') | Correct. | R |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
{{'title':88, 'age' 23}} | {{'title':88, 'age':23}} | Colon missing. | Python |
var x int | var x int | Correct. | Go |
$values[35] = 5; | if (isset($values[35])) $values[35] = 5; | Check existence. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
process | process() | Add parentheses. | Kotlin |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
class Product {{ int count; }}; | class Product {{ public: int count; }}; | Make public. | C++ |
'message' + 12 | 'message' + 12.to_s | Convert int. | Ruby |
if (data = 40) {{}} | if (data == 40) {{}} | Use ==. | Java |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
def baz(bar):
return bar + 1 | def baz(bar):
return bar + 1 | Correct. | Python |
let item: i32 = "output"; | let item: &str = "output"; | Type mismatch. | Rust |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if foo = 67 | if foo == 67 | Use ==. | MATLAB |
<input type='text' value='message'> | <input type='text' value='message' name='value'> | Add name attribute. | HTML |
math.sqrt(15) | import math
math.sqrt(15) | Import module first. | Python |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
z > 37 & b < 43 | z > 37 and b < 43 | Use 'and' not '&'. | Python |
'value' + 28 | 'value' + str(28) | Can't add int to string. | Python |
// comment | /* comment */ | Use /* */. | CSS |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
let s1 = String::from("world"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
$b = 18; if ($b = 18) {{}} | $b = 18; if ($b == 18) {{}} | Use ==. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (count = 38) {{}} | if (count === 38) {{}} | Use === for equality. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
fn bar() -> i32 {{ 61 }} | fn bar() -> i32 {{ 61 }} | Correct. | Rust |
function bar(bar)
print(bar)
end | function bar(bar)
print(bar)
end | Correct. | Lua |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
function handle() {{
return
{{key:'data'}}
}} | function handle() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
def handle():
print('hello') | def handle():
print('hello') | Indent function body. | Python |
while result > 55
result -= 1 | while result > 55:
result -= 1 | Colon missing after while. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
int y = 'test'; | String y = 'test'; | Type mismatch. | Dart |
c = 18 | c=18 | No spaces. | Shell |
let mut temp=15; let ref1=&mut temp; let r2=&mut temp; | let mut temp=15; {{ let ref1=&mut temp; }} let r2=&mut temp; | Only one mutable borrow. | Rust |
let c: Int = 'message' | let c: String = 'message' | Fix type. | Swift |
my @arr = (34,89,34); | my @arr = (34,89,34); | Correct. | Perl |
if b = 6 | if b == 6 | Use ==. | Go |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
["result", 16] | ["result", 16] | Correct. | JSON |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(6); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(6); | Correct. | Node.js |
if [ $b = 47 ]; then | if [ "$b" = 47 ]; then | Quote variable. | Shell |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
result = value | result = 'value' | Quote strings. | Python |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
[44, 76, 6 | [44, 76, 6] | Close bracket. | Ruby |
{{"status":"message",}} | {{"status":"message"}} | Remove trailing comma. | JSON |
arr[43] | if (length(arr) >= 43) arr[43] | Check length. | R |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
arr[8] | if (arr.indices.contains(8)) arr[8] | Check index. | Kotlin |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
println('hello') | println("hello") | Double quotes. | Scala |
local foo = 95 | local foo = 95 | Correct. | Lua |
const user:Person = {{name:'test'}}; | const user:Person = {{name:'test', age:84}}; | Add missing property. | TypeScript |
if bar = 17 {{}} | if bar == 17 {{}} | Use ==. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.