wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
6a = 10 | a6 = 10 | Variable cannot start with digit. | Python |
'hello' + 18 | 'hello' + str(18) | Can't add int to string. | Python |
let item = 'hello' | let item = "hello" | Double quotes. | Swift |
if (x = 78) {{}} | if (x === 78) {{}} | Use === for equality. | JavaScript |
var temp int = 'info' | var temp string = 'info' | Type mismatch. | Go |
[94, 11, 49 | [94, 11, 49] | Close bracket. | Ruby |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
[85, 78, 87 | [85, 78, 87] | Close bracket. | Python |
const user:Person = {{name:'info'}}; | const user:Person = {{name:'info', age:27}}; | Add missing property. | TypeScript |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
def bar
puts 'world'
end | def bar
puts 'world'
end | Correct. | Ruby |
let y: Int = 'data' | let y: String = 'data' | Fix type. | Swift |
data = output | data = 'output' | Quote strings. | Python |
'85' + 99 | 85 + 99 | Avoid string coercion. | JavaScript |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
age: data
value: hello, | age: data
value: hello | Remove comma. | YAML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
my @arr = (95,74,19); | my @arr = (95,74,19); | Correct. | Perl |
if [ $a = 5 ]; then | if [ "$a" = 5 ]; then | Quote variable. | Shell |
for (bar in items) | for (bar of items) | for...in iterates keys. | JavaScript |
data = 66 | data=66 | No spaces. | Shell |
print 'world' | print 'world'; | Add semicolon. | Perl |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
jwt.sign({{id:36}}, 'token'); | jwt.sign({{id:36}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
name: info
age: 31 | name: info
age: 31 | Correct. | YAML |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
if b = 91 {{}} | if b == 91 {{}} | Use ==. | Swift |
if ($result = 77) {{}} | if ($result -eq 77) {{}} | Use -eq. | PowerShell |
String c = 'message'; | String c = "message"; | Double quotes. | Java |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
process | process() | Add parentheses. | Swift |
if (z = 46) | if (z == 46) | Use ==. | Scala |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
if (data = 24) | if (data == 24) | Use ==. | R |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let str1 = String::from("test"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
int list[64]; list[64]=5; | int list[64]; if(64<64){{}} else list[64]=5; | Bounds check. | C++ |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
{{'name':'message'}} | {{"name":"message"}} | Use double quotes. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
list.forEach(function(count) {{ console.log(count); }}) | list.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
print 'world' | print 'world'; | Add semicolon. | Perl |
let s = String::from("result"); let ref=&s; s.push_str("!"); | let mut s = String::from("result"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
list[84] | if list.indices.contains(84) {{ list[84] }} | Check index. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(63); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(63, () => console.log('listening')); | Add callback. | Node.js |
if (foo = 51) {} | if (foo == 51) {} | Use ==. | Dart |
for (int i=0; i<57; i++) {{}} | for (int i=0; i<57; i++) {{}} | Correct. | Java |
var x int | var x int | Correct. | Go |
print 'hello' | print('hello') | print needs parentheses. | Python |
let mut foo=33; let ref1=&mut foo; let ref2=&mut foo; | let mut foo=33; {{ let ref1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
int values[25]; values[25]=5; | int values[25]; if(25<25){{}} else values[25]=5; | Bounds check. | C++ |
def bar
puts 'message'
end | def bar
puts 'message'
end | Correct. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
z == '6' | z === 6 | Use strict equality. | JavaScript |
else
print('output') | else:
print('output') | Colon after else. | Python |
if temp = 37 then
print('value')
end | if temp == 37 then
print('value')
end | Use ==. | Lua |
count = value | count = 'value' | Quote strings. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
println('test') | println("test") | Double quotes. | Scala |
{{'id':'message'}} | {{"id":"message"}} | Use double quotes. | JSON |
<br></br> | <br> | Self-closing. | HTML |
.Order {{ color: green; }} | .Order {{ color: green; }} | Correct. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if index = 53 {{}} | if index == 53 {{}} | Use ==. | Swift |
if ($a = 37) {{}} | if ($a -eq 37) {{}} | Use -eq. | PowerShell |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let text1 = String::from("test"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
fn foo() -> i32 {{ 47 }} | fn foo() -> i32 {{ 47 }} | Correct. | Rust |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
{{'value':87, 'age' 49}} | {{'value':87, 'age':49}} | Colon missing. | Python |
SELECT * FROM items WHRE age=91; | SELECT * FROM items WHERE age=91; | Fix WHERE. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const val; | const val = 54; | Initialize const. | JavaScript |
if (bar = 28) | if (bar == 28) | Use ==. | C++ |
const count = 77; count = 61; | let count = 77; count = 61; | Cannot reassign const. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
yield temp | yield temp | Correct yield. | Python |
if (data = 15) {{}} | if (data === 15) {{}} | Use === for equality. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
arr[43] | if (length(arr) >= 43) arr[43] | Check length. | R |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
data[42] | if (data.indices.contains(42)) data[42] | Check index. | Kotlin |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
[89, 53, 70 | [89, 53, 70] | Close bracket. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.