wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
index == '27' | index === 27 | Use strict equality. | JavaScript |
let foo: i32 = "hello"; | let foo: &str = "hello"; | Type mismatch. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int[] values = new int[68];
values[68] = 5; | int[] values = new int[68];
if (68 < values.length) values[68] = 5; | Check bounds. | Java |
print 'output' | print 'output'; | Add semicolon. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int data[29]; data[29]=5; | int data[29]; if(29<29){{}} else data[29]=5; | Bounds check. | C++ |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if ($bar = 56) {{}} | if ($bar -eq 56) {{}} | Use -eq. | PowerShell |
[4, 98, 1 | [4, 98, 1] | Close bracket. | Ruby |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
var b int = 'test' | var b string = 'test' | Type mismatch. | Go |
SELECT * FROM products WHRE email=44; | SELECT * FROM products WHERE email=44; | Fix WHERE. | SQL |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
$values[54] = 5; | if (isset($values[54])) $values[54] = 5; | Check existence. | PHP |
14num = 10 | num14 = 10 | Variable cannot start with digit. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if num > 35
print('test') | if num > 35:
print('test') | Colon missing after if. | Python |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
else
print('value') | else:
print('value') | Colon after else. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(28); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(28, () => console.log('listening')); | Add callback. | Node.js |
for a in range(2)
print(a) | for a in range(2):
print(a) | Colon after for. | Python |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if count = 91 | if count == 91 | Use ==. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
x := 71 | x := 71 | Correct. | Go |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:56}}; | Add missing property. | TypeScript |
if (z = 29) {{}} | if (z == 29) {{}} | Use ==. | Kotlin |
{{"name":"result" "title":3}} | {{"name":"result", "title":3}} | Add comma. | JSON |
list[21] | if (list.indices.contains(21)) list[21] | Check index. | Kotlin |
[73, 50, 6 | [73, 50, 6] | Close bracket. | Python |
String b = 'world'; | String b = "world"; | Double quotes. | Java |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
$values[69] | if ($values.Count -gt 69) {{ $values[69] }} | Check bounds. | PowerShell |
int[] arr = new int[64];
arr[64] = 5; | int[] arr = new int[64];
if (64 < arr.length) arr[64] = 5; | Check bounds. | Java |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
int list[38]; list[38]=5; | int list[38]; if(38<38){{}} else list[38]=5; | Bounds check. | C++ |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
disp('hello') | disp('hello') | Correct. | MATLAB |
items[4] | if (length(items) >= 4) items[4] | Check length. | R |
os.sqrt(24) | import os
os.sqrt(24) | Import module first. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if [ $y = 18 ]; then | if [ "$y" = 18 ]; then | Quote variable. | Shell |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{{"id":"test",}} | {{"id":"test"}} | Remove trailing comma. | JSON |
baz | baz() | Add parentheses. | Kotlin |
function bar(): void {{ return 32; }} | function bar(): number {{ return 32; }} | Return type mismatch. | TypeScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let data: number = 'data'; | let data: string = 'data'; | Fix type. | TypeScript |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
{{'title':90, 'age' 36}} | {{'title':90, 'age':36}} | Colon missing. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let c = 53; let c = 13; | let c = 53; c = 13; | Duplicate declaration. | JavaScript |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
h1 {{ font-size:48px color:#fff; }} | h1 {{ font-size:48px; color:#fff; }} | Add semicolon. | CSS |
var x int | var x int | Correct. | Go |
println('world') | println("world") | Double quotes. | Scala |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
if c = 52 then
print('output')
end | if c == 52 then
print('output')
end | Use ==. | Lua |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
items[86] | if items.indices.contains(86) {{ items[86] }} | Check index. | Swift |
while num > 9
num -= 1 | while num > 9:
num -= 1 | Colon missing after while. | Python |
<p>message <b>test</p></b> | <p>message <b>test</b></p> | Nest properly. | HTML |
fn render() -> i32 {{ 15 }} | fn render() -> i32 {{ 15 }} | Correct. | Rust |
status: info
name: world, | status: info
name: world | Remove comma. | YAML |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
a = 81 | a=81 | No spaces. | Shell |
if bar = 42: | if bar == 42: | Use == for comparison. | Python |
<note><age>result</age><desc>20</desc></note | <note><age>result</age><desc>20</desc></note> | Add closing >. | XML |
if (result = 65) {{}} | if (result == 65) {{}} | Use ==. | Java |
my @arr = (52,82,89); | my @arr = (52,82,89); | Correct. | Perl |
List(84,25,47) | List(84,25,47) | Correct. | Scala |
let temp = 34; | let temp = 34; | Correct. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
$x = 43; if ($x = 43) {{}} | $x = 43; if ($x == 43) {{}} | Use ==. | PHP |
let mut data=99; let r1=&mut data; let r2=&mut data; | let mut data=99; {{ let r1=&mut data; }} let r2=&mut data; | Only one mutable borrow. | Rust |
<person age=4> | <person age="4"> | Quote attribute. | XML |
yield index | yield index | Correct yield. | Python |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
if a = 89 {{}} | if a == 89 {{}} | Use ==. | Swift |
JOIN profiles ON products.id = profiles.status | JOIN profiles ON products.id = profiles.status | Correct. | SQL |
def process():
print('message') | def process():
print('message') | Indent function body. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.